DOCTYPEs

Browser Test

The document type declaration (DOCTYPE) of a web page decides the rendering mode of most modern web browsers. In turn, the rendering mode determines the browser's interpretation and display of certain web page components.

This utility can be used in modern browsers (such as Internet Explorer 5 (Mac) and 6 (Win), Netscape 6+, Mozilla, and Opera 7) to test their DOCTYPE / rendering mode interpretations.

Selecting a DOCTYPE from the drop-down list below and clicking Test will generate a new web page using that DOCTYPE, with a report of the rendering mode triggered by that DOCTYPE in the currently used browser.

Known issue: Netscape 6 fails the test with "no DOCTYPE" selected.

More Doctype Information

Some web pages have been coded in a haphazard way, or even coded to depend on the proprietary features and rendering misdemeanours of the older (legacy) web browsers. Many web developers now create web page code to comply with the standards of the W3C, using a validator program to check the code against a relevant standard. That standard is specified by a DOCTYPE.

Most modern browsers attempt to accommodate both standards-compliant and legacy / invalid web page code. Such browsers utilise two different modes to render web pages - strict mode (or standards-compliant mode) and quirks mode (or backwards-compatibility mode) - and which of these modes the browser enters is triggered by the DOCTYPE at the start of the web page code. Strict mode renders the page close to W3C standards whereas quirks mode attempts to render the page with legacy browser rendering quirks taken into account. The same web page can render quite differently in strict and quirks modes - with results affecting not only page components and layout, but some scripts as well. A script which accesses a browser's DOM, and which may work happily in quirks mode, can fail miserably in strict mode. If a DOCTYPE is not included in the code of a web page, or an old DOCTYPE is used, a modern browser will enter quirks mode.

However, the browsers have added their quirks to the DOCTYPE subject too. An XML prologue placed before a DOCTYPE will send IE6 (Win) and Opera 7 into quirks mode regardless of the DOCTYPE. Both IE6 (Win) and IE5 (Mac) interpret the following DOCTYPE: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> as strict, whereas N6+ and Mozilla do not. The more recent versions of Mozilla (1.0.1+, including the N7 rendering engine) possess an additional rendering mode - Almost Standards Mode (ASM). ASM is effectively strict mode in everything except the layout of images within table cells, which are rendered as they would be in quirks mode. ASM is reported as strict mode and is triggered by the presence of the following within a DOCTYPE:

-//W3C//DTD XHTML 1.0 Transitional//EN
-//W3C//DTD XHTML 1.0 Frameset//EN
-//W3C//DTD HTML 4.01 Transitional//EN followed by a URI
-//W3C//DTD HTML 4.01 Frameset//EN followed by a URI

This page was created in mid-2002 as a convenient way to test the rendering mode entered by different browsers via some commonly used DOCTYPEs. Information about DOCTYPEs is now more readily available and more clearly documented so this page merely remains as a curiosity. The links below provide further information and tabulated evaluations.

Useful Doctype Links

Opera 7 DOCTYPE Switches
Picking a Rendering Mode (Eric Meyer)
Activating the Right Layout Mode... (Henri Sivonen)
Mozilla's DOCTYPE sniffing (David Baron)