30 out of 59 rated this helpful Rate this topic

!DOCTYPE

.NET Framework 3.0

Specifies the Document Type Definition (DTD) to which the document conforms.

Syntax

HTML  TopElement   Availability  "Registration// Organization// Type  Label// Definition   Language" "URL"

Possible Values

TopElement Specifies the top-level element type declared in the DTD. This corresponds to the Standard Generalized Markup Language (SGML) document type being declared.
HTMLDefault. HTML.
Availability Specifies whether the formal public identifier (FPI) is a publicly accessible object or a system resource.
PUBLICDefault. Publicly accessible object.
SYSTEMSystem resource, such as a local file or URL.
Registration Specifies whether the organization is registered by the International Organization for Standardization (ISO).
+Default. Organization name is registered.
-Organization name is not registered. The Internet Engineering Task Force (IETF) and World Wide Web Consortium (W3C) are not registered ISO organizations.
Organization Specifies a unique label indicating the name of the entity or organization responsible for the creation and maintenance of the DTD being referenced by the !DOCTYPE declaration—the OwnerID.
IETFIETF.
W3CW3C.
Type Specifies the public text class, the type of object being referenced.
DTDDefault. DTD.
Label Specifies the public text description, a unique descriptive name for the public text being referenced. Can be appended with the version number of the public text.
HTMLDefault. HTML.
Definition Specifies the document type definition.
FramesetframeSet documents.
StrictExcludes the presentation attributes and elements that the W3C expects to phase out as support for style sheets matures.
TransitionalContains everything except frameSet elements.
Language Specifies the public text language, the natural language encoding system used in the creation of the referenced object. It is written as an ISO 639 language code (uppercase, two letters).
ENDefault. English language.
URL Specifies the location of the referenced object.

Remarks

This declaration must occur at the beginning of the document, before the html tag.

The !DOCTYPE element does not require a closing tag.

Windows Internet Explorer 8 and later. The !DOCTYPE declaration helps determine the document compatibility mode of a Web page. The document compatibility mode of a Web page determines the level of conformance to industry standards, such as the Cascading Style Sheets, Level 2.1 (CSS2.1) and others. To enable the highest level of standards compliance, verify that your Web pages are rendered using the latest document compatibility mode available. For more information, see Defining Document Compatibility.

You can use this declaration to switch Microsoft Internet Explorer 6 and later into strict standards-compliant mode. You turn the switch on 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 following table shows when standards-compliance is on or off.

DOCTYPE URL Present URL Not Present
No DOCTYPE present off off
HTML (no version) off off
HTML 2.0 off off
HTML 3.0 off off
HTML 4.0 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
Note  In standards-compliant mode, compatibility with other versions of Internet Explorer is not guaranteed. When standards-compliant mode is switched on, the rendering behavior of documents may be different in later versions of Internet Explorer. You should not use this mode for content that is fixed in nature, such as content that is burned on a CD.

Examples

The following examples show how to use the !DOCTYPE declaration to specify the DTD a document conforms to, and to switch Internet Explorer 6 and later to standards-compliant mode.

Both of the declarations in the following example specify conformance to the HTML 4.0 DTD. The second declaration specifies "Strict" conformance to this DTD. The first declaration does not. Both declarations switch Internet Explorer 6 and later to standards-compliant mode.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">

Both of the declarations in this example specify conformance to the "Transitional" HTML 4.0 DTD. The second declaration specifies the URL of the DTD. The first declaration does not. The second declaration switches Internet Explorer 6 and later to standards-compliant mode. 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">

Standards Information

This declaration is defined in HTML 3.2.

See Also

CSS Enhancements in Internet Explorer 6
Did you find this helpful?
(2000 characters remaining)
Community Content Add
Annotations FAQ
Content bug
The syntax for the parameters in the first pair of aphostrophes is stated to be: "Registration// Organization// Type Label // Definition Language"
All the samples has the format: "Registration// Organization// Type Label Definition // Language"  (Definition moved to the left of //)

Definition is also optional and may be absent like in: "-//W3C//DTD HTML 4.0//EN"
Twice as deep
Why is it that if I insert a <div> tag is turns out to be twice as deep as in all other programs? $0$0 $0 $0I can add details if anybody's listening.$0