Web Design
Mobile Internet
Brand Design
Innovative
News
Encyclopedias

Good XHTML writing habits

Date:2015-08-02 Source: Shangpin China Type: website encyclopedia
Word Size: small   medium   big

Since it is XHTML, of course, it is different from HTML. The most clear point is that XHTML is more strict than HTML syntax. When you start writing XHTML, be sure to strictly conform to XHTML's Website production rule of grammar. These rules are mainly reflected in the following aspects:

1. Attribute name must be lowercase

Attributes are common or unique to HTML tags, and can be used to specify a combination of attributes. For example, class is an attribute of an identification type, and align is an attribute used for text alignment. When writing attributes in tags, the English letters of attributes must be lowercase. The correct writing method is as follows:

<span class="blue">

Where, class is an attribute name. In XHTML, such forms as CLASS or Class are not allowed. This is a rule.

2. The attribute value must use double quotation marks

Although filling in the attribute value directly will not cause display problems, XHTML has a rule that the attribute value must be filled in with double quotation marks. We have to follow this rule to avoid unnecessary problems. The correct writing is:

<div id="content">

The form of<div id=content>is not allowed, which is different from the attribute assignment method of HTML tags.

3. Attribute abbreviations are not allowed

Abbreviation attributes are often used in HTML, especially in forms. For example:

<input checked>
<option selected>

XHTML is more strict with this requirement. Abbreviated attributes are not allowed, but must be written in a complete way. Correct writing:

<input checked="checked" />
<option selected="selected" />

4. Use id instead of name

The XHTML specification proposes that the ID is used as a unified name tag, and the name attribute in HTML is no longer recommended.

Note: If we want to write styles for browsers with very low versions, such as IE4 0, the ID and name should exist at the same time. However, with the current browser usage, the name attribute can be discarded.

5. End tag must be used

If the start tag appears on the page, the end tag must appear. For example:

<div></div>
<p></p>

If you use a single label such as img or br, you must end with a forward slash. For example:

<img src="" />
<br/>

From these rules, we need to pay attention to more details in the coding process, but these strict standards also lay a solid foundation for the next step. In general, XHTML is just a relatively strict HTML language. We only need to use it according to certain rules and maintain good writing habits and structural writing methods to easily master it.


Please contact our consultant

+86 10-60259772

Please provide your contact number. The project manager of shangpin China will contact you as soon as possible.