Resources DOCTYPEs

Error: JavaScript is needed to render this site: please enable it.

This gives information about DOCTYPEs.


A DOCTYPE line should appear at the beginning of an HTML or xHTML file to specify the standard applicable to the file. E.g., the DOCTYPE for the HTML 4.01 Strict standard is:


There are two reasons for specifying a DOCTYPE:

NB​: the role of the DOCTYPE in HTML 5 isn’t clear. The draft specification says that it’s required but essentially useless, however, it seems likely that validators, browsers, and other user agents will use it to determine which specification to apply.

The rest of this page presents a list of the doctypes and a discussion of how DOCTYPEs affect rendering.

List of DOCTYPEs 

Here are the DOCTYPEs listed in the various W3C specs:

Note: there is a problem with HTML 5 DOCTYPEs: HTML 5 is not backwards compatible with older versions of HTML. For example, the SUMMARY attribute which is required in the HTML 4 TABLE tag is illegal in HTML 5. For this reason, a page which is pure HTML 4 may not validate with an HTML 5 DOCTYPE.

How DOCTYPES Affect Rendering 

DOCTYPEs affect how pages are rendered in Gecko-based browsers, IE5//Mac, IE6 and IE7, IE8, Opera, and Safari.

Gecko-Based Browsers

These browsers have three modes of rendering pages:

How the mode is chosen is different from IE, and more complex. For details, see the information from Mozilla.

IE 5 [Mac]

This browser has two modes of rendering pages:

Bugwards Compatibility Mode will be chosen if the DOCTYPE is missing, or if it’s a Transitional or Frameset DOCTYPE with no URL. Otherwise Standards Mode will be chosen. [details

IE 6–7

For IE 6 and 7, there are two modes of rendering pages:

How the mode is chosen is a bit different from IE5//Mac, and a bit more complex. For details, see Microsoft’s DOCTYPE page.

Note: IE7 supports standards better with a strict DOCTYPE.

IE 8

For IE 8 the situation is more complex:

Microsoft expects designers to insert the meta tags in current sites until the sites have been updated to make them IE8-compatible.

All this is discussed in Microsoft’s Defining Document Compatibility.

Opera 7–9

The rendering modes depend on the version of Opera. For details, see Henri Sivonen’s DOCTYPE page (the section titled Doctype Sniffing).


This has the same rendering modes as the Gecko-based browsers.

Recommended DOCTYPEs 

I recommend that designers code to the standards as much as possible, normally using one of these DOCTYPEs:

I also recommend that designers use the IE8 metatag which tells IE8 to apply the standards strictly, using one of these metatags:

NB​: IE6 has a bug which requires that an xHTML DOCTYPE appear on the first line of the HTML file for standards mode to be triggered.

An HTML DOCTYPE is theoretically better than an xHTML DOCTYPE, because many browsers don’t specifically support xHTML. I myself use an xHTML DOCTYPE, however, because real-world browsers that don’t support xHTML will render pages fine, just as if they were HTML.

Most of my older sites are xHTML Transitional; newer sites are Strict.

 Top of Page         Legal Notices