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.
Learn more :
W3C: List of valid DTDs
A List Apart: Fixing your site with the right DOCTYPE
WAI guidelines 7.2: HTML version information
List of published formal grammars (as used by the W3C Validation Service )
| Access Guide Home | Table of Contents | Definitions | Glossary |