Since the web quickly commercialized, and fast rollout of proprietary features necessitated lax parsing and rendering of invalid markup, [Tag Soup] proliferated on the web.

With the move towards a more interoperable web, there was a need to find a way to render strictly-written documents according to standards, without breaking the rest of the (incorrect) code on the web. Thus was born the RenderingMode.

The DoctypeSwitch is the hack that enables this change. HTML is an SGML application, and as such, ?some? SGML syntax is allowed (expected, even) in HTML documents. (This is not true for XHTML, since this is an XML application, and not SGML. (XML is a subset of [SGML])) The DOCTYPE declaration, in SGML, provides a means of relating a document instance to a document type definition. It was almost always left out of early HTML files.

Leaving out the DOCTYPE declaration, or using certain other DOCTYPEs will result in QuirksRenderingMode, while using a "modern" DOCTYPE, or using an unknown (perhaps new) DOCTYPE will trigger StrictRenderingMode.

See also:

[ALA DOCTYPE article]

[IE6 DOCTYPE switches]

[Mozilla DOCTYPE switches]

[Opera 7 DOCTYPE Switches] {note older Opera 7 builds followed an IE bug in switching to Quirks mode when a first line xml declaration is present, this was changed in Opera 7.10}

[Matthias Gutfeldt on DOCTYPE switching]

[List of valid DOCTYPEs] provided by the W3C