HTML And XHTML Doctypes

In order to validate any page of HTML or XHTML you will need a doctype. This is a string of text that sits at the top of the document and tells the browser exactly what markup standard has been used to create the page.

XHTML Strict

This doctype is used in an XHTML document when you are not using any framset or depreciated tags.

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

XHTML Transitional

This doctype is used if your XHTML document contains depreciated tags like <b>.<.p>

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

XHTML Frameset

Use this XHTML doctype if your document contains either frameset tags or depreciated tags, or both.

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

HTML Strict

Use this HTML doctype if your document contains no depreciated tags.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

HTML Transitional

Also called loose, this doctype is to be used if your HTML document contains depreciated tags.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML Frameset

This doctype is used in a HTML document that contains frameset tags or depreciated tags or both.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

Without these doctypes in place the browser will default to what is called "quirks mode" where certain CSS styles are looked at a little differently. If you are finding trouble with your stylesheet then try adding a doctype that fits your markup.

Alternatively, if you find that you want your page to validate and adding the doctype tag actually destroys the page then you can add what is called a "broken doctype". This is the same as any normal doctype, but with the URL pointing to the DTD missing. Here are two examples.

XHTML Strict Broken Doctype

This doctype is used in an XHTML document when you are not using any framset or depreciated tags, but still want the page to display in quirks mode and validate properly.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">

HTML Strict Broken Doctype

This doctype is used in an HTML document when you are not using any framset or depreciated tags, but still want the page to display in quirks mode and validate properly.

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

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
4 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.