Home XHTML Tutorial


XHTML is a strict version of HTML. The stricter syntax enables browsers to render the document more easily. This is important for devices with limited computing power such as cell phones. Ideally, all web pages should use XHTML. That's why the EPUB format requires XHTML version 1.1 (the most recent version).

The following highlights the differences between XHTML 1.1 and HTML 4.01.

All tags and attributes must be in lower case.

Wrong: <P>HTML is easy.</P>

Correct: <p>HTML is easy.</p>

Wrong: <p CLASS="value">HTML is easy.</p>

Correct: <p class="value">HTML is easy.</p>

All elements must be closed.

Wrong: <p>HTML is easy.

Correct: <p>HTML is easy.</p>

Wrong: <br>

Correct: <br />

Wrong: <img src="Logo.gif" alt="Logo">

Correct: <img src="Logo.gif" alt="Logo" />

All attribute values must be quoted.

Wrong: <p class=value>HTML is easy.</p>

Correct: <p class="value">HTML is easy.</p>

Correct: <p class='value'>HTML is easy.</p>

The name attribute is replaced by the id attribute.

Wrong: <a name="value">bookmark</a>

Correct: <a id="value">bookmark</a>

Wrong: <img src="Logo.gif" alt="Logo" name="value" />

Correct: <img src="Logo.gif" alt="Logo" id="value" />

All deprecated tags and attributes are invalid.

Deprecated tags: <center>, <font>, <u>.

Deprecated attributes: align, color, bgcolor, target.

These tags and attributes were commonly used in the earlier HTML documents. However, they have been deprecated (not supported) in HTML 4.01. Although most browsers still support them, they cannot be used in an XHTML document. You should use styles to achieve the same styling.

Wrong: <p align="center">HTML is easy.</p>

Correct: <p style="text-align: center">HTML is easy.</p>

Wrong: <p>HTML is <font color="red">easy</font>.</p>

Correct: <p>HTML is <span style="color:red">easy</span>.</p>

Wrong: <p> <a href="/" target="_blank" >Open in a new window</a>.</p>

Correct: None (unless Javascript is used) because opening a linked page in a new window was considered a bad web design. However, in the working draft of HTML 5.0, the target attribute will be restored. HTML 5.0 will integrate XHTML with HTML. There won't be any new version for XHTML (announcement).

 

[From HTML and XHTML Tutorial]