The Beginning of an XHTML Document

The DOCTYPE declaration should always be the first line in an XHTML document

About Document Type Definitions (DTDs)

Be aware that newer browsers (like Internet Explorer 6) might treat your document differently depending on the <!DOCTYPE> declaration. If the browser reads a document with a DOCTYPE, it might treat the document as "correct". Malformed XHTML might fall over and display differently than without a DOCTYPE.


The 3 DTDs

XHTML 1.0 specifies three XML document types that correspond to three DTDs: Strict, Transitional, and Frameset.

XHTML 1.0 Strict

Use this when you want really clean markup, free of presentational clutter. XHTML Strict documents do not permit deprecated tags used for presentation, such as <b>. Instead, they structure content according to its meaning and leave control of the visual presentation to CSS.

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


XHTML 1.0 Transitional

Use this when you need to take advantage of HTML's presentational features and when you want to support graphical browsers that don't understand Cascading Style Sheets.

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


XHTML 1.0 Frameset

A document that uses frames requires a special Frameset doctype so that browsers can correctly understand the hierarchical nature of the page.

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


Additional Requirements

The xml namespace and character set are also required for proper XHTML pages. The xml namespace is put in the html tag right below the doctype and it provides a method to avoid element name conflicts. Put inside of a meta tag, the character set tells the browser what set of characters it will be receiving.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> ... </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body> ... </body>
</html>

Previous: Introduction to XHTML

Next: XHTML Syntax Rules