XHTML: The Differences

XHTML brings uniformity to document structure. The rules of XHTML help restore the structural integrity of documents that was lost during the web's rapid commercial expansion between 1994 and 2001. Unlike old-style HTML pages, valid, well-formed XHTML documents can easily be "transported" to wireless devices, Braille readers and other specialized web environments. Because they follow strict rules and avoid non-standard markup, well-authored XHTML pages are more accessible than old-school HTML pages, helping the library comply with U.S. laws and accessibility guidelines.

 

 

Naturally from HTML 3 to HTML 4.01 your DOCTYPE changed. Similarly from HTML 4.01 to XHTML 1.0 your DOCTYPE must change.

What is a DOCTYPE? It is a declaration at the top of your document. A DOCTYPE, simply put, is a declaration of what standard or specification the web browser should use to interpret the web document. You are telling the web browser that what follows conforms with a certain specification, e.g. XHTML or HTML 4.01. The web browser can then take advantage of this knowledge. It is becoming very important for you to use a DOCTYPE declaration and in fact it is mandatory for XHTML 1.0. If you don't put it in then XHTML 1.0 compliant browsers will not render your page at all.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The xmlns, or XML NameSpace, declaration simply tells the browser, once again, to use the XHTML specification located at W3C. This declaration is carried over from the XML specification and has no correlation in HTML 4.01. People familiar with VML will recognise this usage.

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

Since XHTML is a valid XML specification it is case sensitive. This means that <STRONG> is not the same thing as <strong>.

Not this: <p><b>This is invalid</p></b>
This:<p><b>This is invalid</b></p>

Attribute quotes are the quotes around the value of an attribute. For instance the src attribute of an image must have its value surrounded by quotes, like so: src="images/bob.gif"

An empty tag is a tag such as <img> or <br>. Essentially it is a tag without a closing tag.

Because XHTML is a specification of XML all tags must be closed. Either by <p>closed</p> or by <p />.

So for XHTML all you need to do is make sure you put a / before the closing bracket of any empty tags.

an open and closing tag: <br />