This site is designed for accessibility. Content is obtainable and functional to any browser or Internet device. This site's full visual experience is available in a graphical browser that supports web standards. Please consider upgrading your web browser.

DocType and Browsers Definitions and Notes

Term Meaning
DOCTYPE

DOCTYPE is a means of specifng what syntax the page uses, no more, no less.
Reference

It should appear at the very beginning of an HTML document in order to identify the content of the document as conforming (theoretically) to a particular HTML DTD specification.

It's the component of an SGML document (of which an HTML document is supposed to be an instance in this case) that contains the formal definition of the markup grammar (valid element type names, which elements contain which, valid attribute names, etc.) An SGML parser has to process these definitions before it can check the instance markup. A shorthand form of the _document type declaration_ is where some or all of these formal definitions are gathered together in a separate file and incorporated much like a '#include' preprocessor statement would work in C. An _external identifier_ like "-//W3C//DTD HTML 4.01 Transitional" is a location- and context-independent name for such a file. (You'll here a whole bunch of mythology to the effect that this name is about the HTML spec itself, or about how HTML semantics are announced, but all of that is bogus.)

DOCTYPE switching

Switching is the mechanism by which browsers examine the DOCTYPE (or lack thereof) contained in a document, and picks a rendering mode to match it.

Typically, older or malformed DOCTYPEs cause browsers to enter "quirks" mode, which emulates historical authoring practices built around the flaws found in older browsers. Newer DOCTYPEs will trigger "strict" mode, where they attempt to hew as closely as possible to the W3C recommendations in order to deliver a more consistent cross-browser experience.

This lets authors decide which mode to use, a decision which is generally fueled by their target audience.

Note: the browser doesn't actually use the DOCTYPE to validate the content -- it only uses this string to toggle specific behavior of the renderer.

DOCTYPES examples THAT WORK

HTML 4.01 Strict, Transitional, Frameset

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

XHTML 1.0 Strict, Transitional, Frameset

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

XHTML 1.1 DTD

  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Quirks mode

Using an incomplete or outdated DOCTYPE—or no DOCTYPE at all—throws browsers into “Quirks” mode, where the browser assumes you’ve written old-fashioned, invalid markup and code per the depressing industry norms of the late 1990s.

In this setting, the browser will attempt to parse your page in backward–compatible fashion, rendering your CSS as it might have looked in IE4, and reverting to a proprietary, browser–specific DOM.

standards/strict mode A recent DOCTYPE that includes a full URI (a complete web address) tells these browsers to render your page in standards–compliant mode, treating your (X)HTML, CSS, and DOM as you expect them to be treated.