


Detailed introduction to formatting XML documents using CSS stylesheets
This article is suitable for friends who have a certain CSS foundation. If you don’t have the foundation of CSS, you can go to Chinesew3schools to learn.
1、XML is introduced in CSS styles.
Introduced CSS style sheet into XML Two methods. One is to embed the CSS style directly in the XML document; the other is to introduce it externally (it seems to be in # Many introduction methods in ##WEB have these two methods). The method to directly embed the CSS style in XML is as follows:
1 <?xml version="1.0" encoding="utf-8"?> 2 <?xml-stylesheet type="text/css"?> 3 <xml> 4 <HTML:STYLE xmlns:HTML="http://www.w3.org/profiles/XHTML-transitional"> 5 book{ 6 display:block; 7 background-color:#FFE4C4; 8 margin:5px; 9 } 10 name{ 11 display:block; 12 line-height:30px; 13 } 14 author{ 15 display:block; 16 line-height:30px; 17 } 18 date{ 19 display:block; 20 line-height:30px; 21 } 22 </HTML:STYLE> 23 <book> 24 <name>Xml应用系列</name> 25 <author>学路的小孩</author> 26 <date>2009-03-23</date> 27 </book> 28 </xml>
Code Description: The first line is the header declaration of the XML file, as a well-formed Xml documents should add header declaration information. The second line is the declaration of the CSS style, where xml-stylesheet means XMLAdd a style sheet to the document, type="text/css" means the type of style sheet is CSS Style sheet. The content between the fourth line and the 22nd line is the CSS style content, of which the fourth line is used to declare the addition of CSSCode, line 22 is its closing tag. The following lines are the contents of the XML document. After adding the CSS style, we open this XML in IE Document, the effect is as follows:
第二种方式是外部引用。外部引用的代码示例如下:
1 <?xml version="1.0" encoding="utf-8"?> 2 <?xml-stylesheet type="text/css" href="bookstyle.css"?> 3 <xml> 4 <book> 5 <name>Xml应用系列</name> 6 <author>学路的小孩</author> 7 <date>2009-03-23</date> 8 </book> 9 </xml>
代码说明: 第一行为Xml文档的声明;第二行中添加了一个href属性,它表示引入外部的CSS文件,文件的名字是bookstyle.css。后面的几行是XML文档的内容。我在bookstyle.css中写入的样式如下:
1 book{ 2 display:block; 3 background-color:gray; 4 margin:5px; 5 } 6 name{ 7 display:block; 8 line-height:30px; 9 } 10 author{ 11 display:block; 12 line-height:30px; 13 } 14 date{ 15 display:block; 16 line-height:30px; 17 }
这个样式跟第一个样式的唯一区别就是背景改为了gray,在IE中显示的效果为:
2、CSS设置XML文档的显示效果
Use selectors in CSS to format XML documents. The selector is generally one or more XML tags, such as the above book, name , etc., the attributes and attribute values displayed in curly braces are separated by colons. Using CSS, you can set whether the label content is displayed through the dispaly attribute. The attribute value is none, block, inline, list-item. In addition, CSS can also set the font, color, text, margin, border, filling and positioning display of XML. These usage methods are the same as those used in HTML, so they will not be explained in detail here. The next article will explain how to use XSLT to template XML documents. Friends who like it, please continue to pay attention.
The above is the detailed content of Detailed introduction to formatting XML documents using CSS stylesheets. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
