1. All tags must have a corresponding closing tag
Previously in HTML, you could open many tags, such as <p> and <li> without necessarily writing the corresponding </p> and </li> to close them. But this is not legal in XHTML. XHTML requires a strict structure and all tags must be closed. If it is a separate unpaired tag, add a "/" at the end of the tag to close it. For example:
<br /><img height="80" alt="Web Designer" src="../images/logo_w3cn_200x80.gif" width="200" />
2. The names of all tag elements and attributes must be in lowercase
Unlike HTML, XHTML is case-sensitive, and <title> and <TITLE> are different tags. XHTML requires that all tag and attribute names must be lowercase. For example: <BODY> must be written as <body>. Mixed case is also not recognized. Usually the attribute name "onMouseOver" automatically generated by Dreamweaver must also be changed to "onmouseover".
3. All XML tags must be properly nested
Also because XHTML requires a strict structure, all nesting must be in order. Previously we wrote the code like this:
<p><b></p></b>
Must be modified to:
<p><b></b></p>
That is to say, the nesting layer by layer must be strictly symmetrical.
4. All attributes must be enclosed in quotation marks ""
In HTML, you don't need to quote attribute values, but in XHTML, they must be quoted. For example:
<height=80>
Must be modified to:
<height="80">
In special cases, you need to use double quotes in the attribute value, you can use ", and single quotes can use ', for example:
<alt="say'hello'">
5. Encode all < and & special symbols
Any less-than sign (<) that is not part of a tag must be encoded as <
Any greater-than sign (>) that is not part of a label must be encoded as >
Any ampersand (&) that is not part of an entity must be encoded as & amp;
Note: There are no spaces between the above characters.
6. Assign a value to all attributes
XHTML stipulates that all attributes must have a value, and if there is no value, it will repeat itself. For example:
<td nowrap> <input type="checkbox" name="shirt" value="medium" checked>
Must be modified to:
<td nowrap="nowrap"> <input type="checkbox" name="shirt" value="medium" checked="checked">
7. Do not use "--" in the comment content
"--" can only occur at the beginning and end of XHTML comments, that is, within the content they are no longer valid. For example, the following code is invalid:
<!--Comments here----------Comments here-->
Replace internal dotted lines with equal signs or spaces.
<!--Comments here============Comments here-->
Some of the above specifications may seem strange, but they are all designed to make our code have a unified and unique standard to facilitate future data reuse.