Here’s a quick check list of the important requirements of XHTML and the differences between HTML and XHTML.

This is NOT a comprehensive XHTML language reference.

All tags, attributes and values must be written in lowercase.

Right: <a href=”” >
Wrong: <A HREF=”” >

All attribute values must be within quotes

Right: <a href=”” >
Wrong: <a >

All tags must be properly nested

Right: <em>this emphasis just keeps getting <strong>stronger and stronger</strong></em>
Wrong: <em>this emphasis just keeps getting <strong>stronger and stronger</em></strong>

All XHTML documents must carry a DOCTYPE definition

The DOCTYPE is an intimidating looking piece of code that must appear at the start of every XHTML document, it tells the browser how to render the document.

Rules for the DOCTYPE tag:

* It must be the first tag in the document
* The DOCTYPE is not actually part of the XHTML document so don’t add a closing slash
* It should point to a valid definition file called a DTD that tells the browser how to read the document
* You must write the DOCTYPE tag correctly otherwise your document will explode (into little pieces of HTML called “tag soup”) and be unvalidatable.

There are three types of valid XHTML 1.0 document: Strict, Transitional, and Frameset. If you can get your document to validate with “Strict” then do so, however some legacy tags and attributes aren’t allowed in Strict so you can use “Transitional” instead.

Note also that using a Transitional DTD takes most browsers out of “Standards” mode. It is much trickier to get your web pages to look consistent across different browsers when the browsers are not in Standards mode. I’m not going to explain the minutae of the DOCTYPE tag as it gets deeper and more complicated, just know that for best results you should use one of the following, preferably the first one (Strict):

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

The HTML tag must contain an XMLNS attribute

You don’t need to understand the “XML namespace” attribute, except to know that it is required in all XHTML documents. Here is an example of how to write it:

<html xmlns=””>

Documents must be properly formed with HTML, HEAD, TITLE and BODY tags

In HTML it is possible to write a webpage that contains none of the above tags; in XHTML it is not. The above tags must be included and they must be nested and ordered correctly, as follows (the DOCTYPE has been omitted):

<html xmlns=””>

See how the TITLE must be placed in the document HEAD – the TITLE is considered
to be a “required child” element of the HEAD.
Notice that the HEAD must also appear before the document BODY.
Notice also how both the HEAD and the BODY must be contained
within the HTML tag. Again, HEAD and BODY are “required child”
elements of the HTML tag. Finally, notice that this text is
written within a <p>paragraph</p> tag; in XHTML you may
not write text directly in the BODY tag without using a suitable
container tag, such as <p> or <div>.

All tags must be closed, even single tags


<p>Mary had a little lamb
<p>It’s fleece was white as snow


<p>Mary had a little lamb</p>
<p>It’s fleece was white as snow</p>

In XHTML even single tags have to be closed – absolutely NO tag may be left open.

Wrong:<p>Mary had a little lamb <br>It’s fleece was white as snow</p>

Right: <p> Mary had a little lamb <br/> It’s fleece was white as snow</p>

Attribute minimisation isn’t allowed

In HTML, attributes can be strung together almost like they were keywords, ie. <dl compact>, this is called attribute minimisation. In XHTML that is not allowed, attributes and values must be excplicit, ie.

<dl compact=”compact”>

ID and NAME attributes

In HTML it was legal to use ID and NAME attributes interchangeably. In XHTML the NAME attribute is formally deprecated and cannot be used. In all cases where you would think to use a NAME attribute you must now use ID instead. e.g.

Correct HTML: <input type=”submit” name=”s” value=” Search ” >

Correct XHTML:<input type=”submit” id=”s” value=” Search ” />

STYLE is all in your HEAD

XHTML does not allow STYLE or SCRIPT declarations within the body of a document they must be placed in the document HEAD instead.