Latest web development tutorials

HTML <! DOCTYPE> declaration

Examples

<! DOCTYPE html> <Html> <Head> <Meta charset = "utf-8"> <Title> Document Title </ title> </ Head> <Body> content of the document ...... </ body> </ Html>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <! DOCTYPE> declaration.


Tag definitions and instructions

<! DOCTYPE> declaration in the document in the foremost position, before the <html> tag in.

<! DOCTYPE> declaration is not an HTML tag; it is used to tell the Web browser page which uses the HTML version.

In HTML 4.01, <! DOCTYPE> declaration required reference DTD (document type declaration), since HTML 4.01 is based on SGML (Standard Generalized Markup Language Standard Generalized Markup Language). DTD specifies the rules for markup language to ensure that the browser can properly render content.

HTML5 is not based on SGML, and therefore does not require a reference DTD.

Tip: Always give your HTML document to add a statement to ensure that the browser can know the document type <DOCTYPE!>.


Differences between HTML 4.01 and HTML5

HTML 4.01 specifies three different statements, namely <DOCTYPE!>: Strict, Transitional, and Frameset. HTML5 specifies only one of:

<!DOCTYPE html>


HTML elements and Doctypes

See HTML elements and legitimate Doctype , look at each HTML element which appears in the Doctype.


Tips and Notes

NOTE: <! DOCTYPE> tag has no end tag.

Tip: <! DOCTYPE> declaration is not case-sensitive.

Tip: Use verify the W3C check if you write HTML with a legitimate right of the DTD / XHTML document!


Common DOCTYPE declaration

HTML 5

<!DOCTYPE html>

HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does not include representation or obsolete elements (such as font). Frame set is not allowed.

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

HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, including appearance or obsolete elements (such as font). Frame set is not allowed.

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

HTML 4.01 Frameset

The DTD HTML 4.01 Transitional and the same, but allows the use of frameset content.

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

XHTML 1.0 Strict

This DTD contains all HTML elements and attributes, but does not include representation or obsolete elements (such as font). Frame set is not allowed. Structure must be written according to the XML standard format.

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

XHTML 1.0 Transitional

This DTD contains all HTML elements and attributes, including appearance or obsolete elements (such as font). Frame set is not allowed. Structure must be written according to the XML standard format.

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

XHTML 1.0 Frameset

The DTD XHTML 1.0 Transitional and the same, but allows the use of frameset content.

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

XHTML 1.1

The DTD XHTML with the same 1.0 Strict, but allows you to add a module (for example to provide ruby ​​support for East Asian languages).

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