Seven basic XHTML Codes

Source: Internet
Author: User

Seven basic XHTML Codes

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. Example: <br/>
2. All tag elements and attribute names 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 XHTML tags must be reasonably nestedSimilarly, 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 to: <p> <B> </B>/P> that is, nesting at a layer must be strictly symmetric.
4. All attributes must be enclosed by quotation marksIn 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 changed to <Height = "80"> in special cases, you need to use double quotation marks in the attribute values. You can use ", you can use & apos; for example, <alt = "say & apos; Hello & apos;">
5. encode all <and & special charactersAny minor sign (<), not part of the tag, must be encoded as & L t; any major sign (>), not part of the tag, must be encoded as & g t; any ampersand (&), not part of an object, must be encoded as & A m p. Note: There is no space between the above characters.
6. assign a value to all attributesXHTML 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 changed: <TD nowrap = "nowrap"> <input type = "checkbox" name = "shirt" value = "medium" Checked = "checked">
7. Do not add "-" to the comment."-" 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-> use the equal sign or space to replace the internal dotted line. <! -Here is the comment ================ here is the comment-> some of the above specifications seem strange, but all this is to make our code have a unified and unique standard, so as to facilitate future data reuse. Original article address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.