You may have noticed in the previous section that the biggest difference between an XHTML file and a plain text file is the use of & ldquo; & lt; & gt; & rdquo; such as & lt; body & gt ;. We call them tags. In general, XHTML labels appear in pairs, such as & lt; html & gt ;. We can see that they only differ by one & ldqu
Introduction to XHTML labels
You may have noticed in the previous section that the biggest difference between an XHTML file and a plain text file is that it contains "<>", for example. We call them tags. Usually, XHTML labels appear in pairs, for example. We can see that they only differ by one "/".The tag without "/" is called the start tag, and it corresponds to "/"The end tag is called the end tag. The end tag is different from the start tag by only one "/" symbol. Of course, some tags in XHTML do not appear in pairs, and they do not terminate tags. We call these tags "Empty tags ". The content of the empty tag will be mentioned later in the tutorial.
Case sensitivity
Previous versions of HTML tags are not case sensitive, such as tagsAnd labelsIs equivalent. In XHTML, all labels are in lower case. In order to make your website conform to the XHTML standard, you should develop a good habit of using lowercase letters for all tags during webpage creation.
Functions (elements) of XHTML labels)
Open the html file saved in the previous tutorial. "This is my first web page ." Change to "this is my first
Webpage.", Save the modification and browse the webpage again. You will find that the two words on the webpage are displayed in bold, and the effect is as follows:
This is my first
Webpage.
The difference is obvious. Because the web page is labeled as a "package ",
In bold.
The label is displayed in bold, but it only affects the content contained by it. This is how the XHTML tag works. We call the content wrapped by tags an element. In this example, the word "webpage" isLabel element. Tag attributes
We can set some attributes for the XHTML tag. Pay attention to the above horizontal line. Its original code is: . In XHTML, a label is a horizontal split line. We can add an attribute "size" (that is, the size of the split line) for this split line. Its attribute value is 1. The complete code is:
Similarly, the method for adding attributes to other XHTML tags is to add attribute = "attribute value" to the tag's starting tag ". Note that the attribute values must be enclosed in quotation marks. Single or double quotation marks are acceptable, but double quotation marks are commonly used.
Format of the property to be added: <起始标签 属性="属性值"> Instance>
Note: There are two levels of standard (not framework standard) for common XHTML files-transition standard and strict standard. The transition standard is mainly for webmasters who are used to HTML development websites. The above code is valid in the transition standard, but in strict standards, the size attribute is regarded as invalid. XHTML is not only a more standard HTML, but also a way of building websites. That is, the content and style of the webpage are separated, which is implemented through CSS in XHTML. Therefore, we recommend that you use the strictly standard XHTML to submit the task of defining styles to CSS. (The question about the XHTML standard will be described in the following tutorial) Empty tagYou may have noticed that the split line label is not symmetric here.Is written. In fact, this is the unpaired tag we mentioned in the previous tutorial. It has only the starting tag but not the ending tag.. Because it has no elements, we call such a label an empty tag. Why should we writeInstead of simply writing it? This writing format is used to meet the rule that "close" is required for any tags in XHTML. The method for adding "/" at the end of the starting tag is called the tag auto-closing (or auto-closing or auto-termination ).The methods for using all null tags are the same, that is, add a space and a backslash (/) before the ">" symbol of the start tag. Spaces are not mandatory, but cannot be recognized by some browsers., Can only be recognized. This is why we add spaces. (I have not met any incompatible browsers so far)