[Skip navigation]

DEMOS Project

Online Materials for Staff Disability Awareness
: Techniques

Declaring the HTML version:
DTD (document type definition) / DOCTYPE

It is important to include a document type definition (DTD) at the very beginning of each webpage. It is a declaration of which formal grammar rules (which version of HTML) were used in writing the code for a page. The user agent (browser) can then interpret and render the page correctly. Especially newer browsers have the ability to render pages according to the DOCTYPE declaration. A document will not validate without it.

For example, the following DOCTYPE states that this document was written using XHTML transitional (as opposed to 'strict') and refers to the page where the grammar for this version is documented. XHTML 1.0 is the most recent recommendation from the W3C for authoring webpages.

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

Using the correct document type definition means that even a site build with an older version of HTML (e.g. HTML 3.2), which might include deprecated code like FONT tags, will still validate and render properly.

Some useful links:

WAI guidelines 7.2: HTML version information [External link: Open in new browser window]

List of published formal grammars [External link: Open in new browser window]
(as used by the W3C Validation Service [External link: Open in new browser window] )

XHTML 1.0 Specifications [External link: Open in new browser window]

A List Apart: Fixing your site with the right DOCTYPE [External link: Open in new browser window]


[Previous] | Previous || Table of Contents || Next | [Next]