<!DOCTYPE> Declaration
The Document Type Declaration (DTD) specifies the rules for the markup language, so that browsers can render the content correctly.
Note: The doctype declaration should be the very first line in an HTML document.
The doctype declaration for HTML5 has the form:
<!DOCTYPE root-element>
Element | Description |
---|---|
root-element | The root element of an HTML document is <html> which is the first element opened and last element closed |
HTML5
Contains all HTML5 elements and attributes. There is no need to specify a reference to a DTD.
<!DOCTYPE html>
Older Doctypes
HTML 2.0
This doctype is widely supported by browsers but lacks support for most commonly used presentational elements and attributes, tables, frames, and internationalization.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
HTML 3.2
This doctype is supported by most browsers but has limited support for style sheets and no support for HTML4 features such as frames and internationalization.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
HTML4.x
The doctype declarations for HTML4.x have the form:
<!DOCTYPE root-element PUBLIC "FPI" ["URI"]> or <!DOCTYPE root-element SYSTEM ["URI"]>
Element | Description |
---|---|
root-element | The root element of an HTML document is <html> which is the first element opened and last element closed |
PUBLIC | Indicates a public DTD |
SYSTEM | Indicates a private DTD |
FPI | A Formal Public Identifier used to uniquely identify the specification. |
URI | The Uniform Resource Identifier of the DTD |
For HTML4.x, there are three HTML DTDs:
- Strict
- Transitional
- Frameset
HTML4.01 Strict
Contains all HTML elements and attributes, but DOES NOT include presentational or deprecated elements. Framesets are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML4.01 Transitional
Contains all HTML elements and attributes, INCLUDING presentational and deprecated elements. Framesets are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML4.01 Frameset
Same as HTML4.01 Transitional, but allows frameset content.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|