ArticleDirectory
- 1. All tags must have an ending mark.
- 2. The element and attribute names of all tags must be in lower case.
- 3. All XML tags must be reasonably nested.
- 4. All attributes must be enclosed by quotation marks ("").
- 5. encode all <and & special characters
- 6. assign a value to all attributes
- 7. Do not make "--" in the comment content
Before starting official content production, we must first understand the web standardsCode. Understanding these specifications can help you avoid detours and pass code verification as soon as possible.
1. All tags must have an ending mark.
Previously, in HTML, you can open many tags, such as <p> and <li>, but not necessarily write the corresponding </P> and </LI> to close them. However, this is invalid in XHTML. XHTML requires a rigorous structure, and all labels must be disabled. If it is an unpaired tag, add "/" at the end of the tag to close it. For example:
<Br/>
2. The element and attribute names of all tags must be in lower case.
Unlike HTML, XHTML is case sensitive and <title> are different tags. XHTML requires that all labels and attribute names must be in lower case. For example, <body> must be written as <body>. Case-insensitive inclusion is not recognized. Generally, the attribute name "onmouseover" automatically generated by Dreamweaver must be changed to "onmouseover ".
3. All XML tags must be reasonably nested.
Similarly, because XHTML requires a rigorous structure, all nesting must be in order. Previously we wrote code like this:
<P> <B> </P>/B>
Must be modified:
<P> <B> </B>/P>
That is to say, the nesting layer by layer must be strictly symmetric.
4. All attributes must be enclosed by quotation marks ("").
In HTML, you do not need to enclose attribute values in quotation marks, but in XHTML, they must be enclosed in quotation marks. For example:
<Height = 80>
Must be modified:
<Height = "80">
In special cases, you need to use double quotation marks in the property values. You can use ", single quotation marks can use & apos;, for example:
<Alt = "say & apos; Hello & apos;">
5. encode all <and & special characters
- Any minor sign (<), not part of a tag, must be encoded& L t;
- Any greater than (>), not part of a tag, must be encoded& G t;
- Any ampersand (&), not part of an object, must be encoded& A m p;
Note: There is no space between the above characters.
6. assign a value to all attributes
XHTML specifies that all attributes must have a value. If there is no value, it repeats itself. For example:
<TD nowrap> <Input type = "checkbox" name = "shirt" value = "medium" Checked>
Must be modified:
<TD nowrap = "nowrap"> <Input type = "checkbox" name = "shirt" value = "medium" Checked = "checked">
7. Do not make "--" in the comment content
"--" Can only occur at the beginning and end of the XHTML comment, that is, they are no longer valid in the content. For example, the following code is invalid:
<! -- Here is the comment ----------- here is the comment -->
Replace the dotted line with equal signs or spaces.
<! -- Here is the comment ============= here is the comment -->
Some of the above specifications seem strange, but they all aim to make our code have a unified and unique standard, so that we can reuse data in the future.