HTML Tag Reference - HTML tag <!DOCTYPE>








This element <!DOCTYPE> specifies the document type definition (DTD) for to the document. It must appear before the HTML tag.

The <!DOCTYPE> declaration tells the web browser about the version of HTML. The <!DOCTYPE> statement should be used as the first line of all documents.

Validation programs might use this construct when determining the correctness of an HTML document.

The <!DOCTYPE> declaration is NOT case sensitive.

In HTML 4.01, the <!DOCTYPE> declaration refers to a DTD. The DTD specifies the rules for the markup language.

Browser compatibility

<!DOCTYPE> Yes Yes Yes Yes Yes




What's new in HTML5

There are three different <!DOCTYPE> declarations in HTML 4.01. In HTML5 there is only one, which is <!DOCTYPE html>.

Attribute

Common DOCTYPE Declarations

The following code is the HTML 5 DOCTYPE Declarations.

<!DOCTYPE html>

The following code is for HTML 4.01 Strict DOCTYPE Declarations.

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

HTML 4.01 Transitional

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

HTML 4.01 Frameset

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

XHTML 1.0 Strict

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

XHTML 1.0 Transitional

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

XHTML 1.0 Frameset

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

XHTML 1.1

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




Example

A demo showing how to use DOCTYPE element.

<!DOCTYPE HTML>
<html>
<body>
</body>
</html>