DOCTYPE - DTD - Document Type Declaration

The DOCTYPE Declaration (DTD or Document Type Declaration), what it does and why each web page needs it. HTML validation requires the DOCTYPE declaration (DTD). The browsers will go into Quirks mode if a DOCTYPE declaration (DTD) is not included.

What Does DOCTYPE Declaration (DTD) Stand for?

DOCTYPE Declaration is the abbreviation for Document Type Declaration (DTD).

What Does the DOCTYPE Declaration (DTD) Do?

The DOCTYPE Declaration (DTD or Document Type Declaration) does a couple of things:

  1. When performing HTML validation testing on a web page it tells the HTML (HyperText Markup Language) validator which version of (X)HTML standard the web page coding is supposed to comply with. When you validate your web page the HTML validator checks the coding against the applicable standard then reports which portions of the coding do not pass HTML validation (are not compliant).
  2. It tells the browser how to render the page in standards compliant mode.

Which DOCTYPE Declaration Should I Use?

If you are a beginner to HTML (HyperText Markup Language) then I would suggest you use the HTML 4.01 Transitional declaration. It is much more forgiving for the beginner when performing HTML validation. You would also use this declaration if you know that your audience will not have a browser that supports CSS (Cascading Style Sheets).

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

This DOCTYPE declaration still allows elements and presentation attributes that should be in the stylesheet.

If you want to learn to code in preparation for the future but still not ready for XHTML then you would use the Strict declaration.


With this declaration all presentation attributes are moved to the stylesheet.

A complete list of DOCTYPE Declarations (DTDs) is available at List of valid DTDs you can use in your document.

What Happens If the DOCTYPE Declaration (DTD) is Not Included or is Incorrect?

If the web page coding does not include a DOCTYPE Declaration (DTD or Document Type Declaration) or it is done incorrectly:

  1. You will not be able to use a HTML (HyperText Markup Language) Validator to check the page coding. HTML validation requires the DOCTYPE declaration.
  2. The browser rending the web page will process the coding in Quirks Mode.
  3. The stylesheet may not be implemented as planned.

DOCTYPE Switching

Using the correct DOCTYPE Declaration (DTD or Document Type Declaration) is important. Compliant browsers have the technology to switch between Standards and Quirks mode. If the correct DOCTYPE Declaration is used the browser switches to Standards mode.

Compliant browsers have 2 modes, Quirk and Standard.

If you are interested in how each browser reacts to the different DOCTYPE Declarations there is a table available at Doctypes and their respective layout mode

To see an example of how a page will be rendered in each mode 'Standards' vs 'Quirks' modes Note: This example is for XHTML but it still demonstrates what happens when the browser uses each mode.


To learn more about HTML code validation:

If you found this web page a useful resource for your own website please link as follows:

HTML Basic Tutor -

The DOCTYPE Declaration (DTD or Document Type Declaration), what it does and why each web page needs it.