5th days of website construction using web standards: XHTML code specification

Source: Internet
Author: User

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 the tag, must be encoded as & l t;

Any greater than sign (>) is not part of the tag and 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 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.

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.