Differences Between XHTML 1 and HTML 4


XHTML 1.1 is an improved version of HTML 4 that plays by the more rigid rules of XML. Fortunately, most of the differences between XHTML and HTML don't dramatically impact the overall structure of HTML documents. Migrating an HTML document to XHTML is more a matter of cleaning and tightening up the code than converting it to a new language.

Following is a list of the primary differences between XHTML and HTML, with a focus on what XHTML requires that HTML doesn't:

  • Element and attribute names must be in lowercase (<a href="index.html">).

  • End tags are required for non-empty elements (<p>Howdy!</p>).

  • Empty elements must consist of a start-tag/end-tag pair or an empty element (<br />).

  • Attribute values must always be quoted (href="index.html").

  • Attribute names cannot be used without a value (ismap="ismap").

  • The XHTML namespace must be declared in the html element.

  • The head and body elements cannot be omitted.

  • The title element must be the first element in the head element.

  • Documents must use the id attribute to uniquely name elements on the page; the name attribute can no longer be used in XHTML for this purpose.

Based on your newfound knowledge of XML, none of these differences should come as too much of a surprise, especially because you've been following the rules of XHTML throughout the book. Fortunately, they are all pretty easy to find and fix in HTML documents, which makes the move from HTML to XHTML relatively straightforward.




SAMS Teach Yourself HTML and CSS in 24 Hours
Sams Teach Yourself HTML and CSS in 24 Hours (7th Edition)
ISBN: 0672328410
EAN: 2147483647
Year: 2005
Pages: 345

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net