Wednesday, May 2, 2012

HTML Advanced tutorial 31 : HTML to XHTML

A website can be converted from HTML to XHTML by applying following 6 simple steps.

1. Add a <!DOCTYPE> : 
Add an XHTML <!DOCTYPE> to the first line of every page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2. Add an xmlns Attribute :
Add an xmlns attribute to the html element of every page.

<html xmlns="http://www.w3.org/1999/xhtml">

3. Change Tags And Attribute Names to Lowercase :
Replace all uppercase tags and attributes with lowercase tags and attributes respectively.

4. Quote All Attribute Values :
In every page, make sure that attribute values are quoted.

5. Close all Empty Tags :
Empty tags are not allowed in XHTML. The <hr> and <br> tags should be replaced with <hr /> and <br/>.

6. Validate XHTML With The W3C Validator :
Before an XHTML file can be validated, a correct DTD must be added as the first line of the file. Validate the document by url here,  http://validator.w3.org/ .
Correct errors if any found.

<<  HTML Advanced tutorial 30 : XHTML Doctypes

No comments:

Post a Comment