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>.


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.


HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

HTML 4.01 Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">


A demo showing how to use DOCTYPE element.