The !DOCTYPE "Switch"
This section describes how to use the !DOCTYPE declaration in your document to switch on standards-compliant mode with Internet Explorer 6 or later.
You switch on standards-compliant mode by including the !DOCTYPE declaration at the top of your document, specifying a valid Label in the declaration, and in some cases, specifying the Definition and/or URL. The Label specifies the unique name of the DTD, and can be appended with the version number of the DTD. The Definition specifies the definition of the DTD that is specified in the Label. The URL specifies the location of the DTD.
There are three Definitions specified in the HTML 4.0 specification—Frameset, Transitional, and Strict. Frameset is used for FRAMESET documents. Transitional contains everything except FRAMESET documents, and Strict, according to the HTML 4.0 specification, "...excludes the presentation attributes and elements the World Wide Web Consortium (W3C) expects to phase out as support for style sheets matures."
The following table shows which values of the !DOCTYPE declaration switch on standards-compliant mode with Internet Explorer 6 or later.
Label Definition URL present URL not present
No !DOCTYPE present Off Off
HTML (No Version Present) Off Off
HTML 2.0 Off Off
HTML 3.0 Off Off
HTML 3.2 Off Off
HTML 4.0 No Definition Present On On
HTML 4.0 Frameset On Off
HTML 4.0 Transitional On Off
HTML 4.0 Strict On On
XHTML On On
XML On On
Unrecognized !DOCTYPE On On
The preceding table shows that standards-compliant mode is switched off when the !DOCTYPE declaration is not present in the document, when the Label in the declaration doesn't specify a version of the HTML specification, or when it specifies a version earlier than HTML 4.0. When you specify the Frameset or Transitional Definition of HTML 4.0 in your !DOCTYPE declaration, the table shows that standards-compliant mode is switched on only when you include the URL. Standards-compliant mode is also switched on when you specify the Strict Definition of HTML 4.0 in your !DOCTYPE declaration, and when you specify HTML 4.0 with no Definition.
To allow for the creation of new DTDs, such as HiDad 11.22, standards-compliant mode is switched on when the !DOCTYPE declaration is not recognized. Standards-compliant mode is also switched on when you specify a version of HTML that is not listed in the table, such as HTML 1.0 or HTML 3.22.
!DOCTYPE Examples
The examples in this section show how to use the !DOCTYPE declaration to specify the DTD to which a document conforms and how to switch on standards-compliant mode.
Both of the declarations in the following example specify conformance to the Transitional HTML4.0 DTD. The second declaration specifies the URL of the DTD. The first declaration does not. The second declaration switches on standards-compliant mode with Internet Explorer 6 or later. The first declaration does not.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Both of the declarations in the following example specify conformance to the HTML 4.0 DTD. The first declaration does not specify a Definition. The second declaration specifies the Strict Definition of this DTD. Neither declaration specifies the URL. Both of these declarations switch on standards-compliant mode.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">