HTML <!DOCTYPE> Declaration

The <!DOCTYPE> declaration specifies the HTML version used in the document. Every HTML document should start with this declaration so that the browsers can render the page compliant with HTML standards.

The <!DOCTYPE> is declared before the <html> tag. The declaration is not case sensitive.

<!DOCTYPE> Syntax

[Root element] [Publicity] "[Registration]//[Organization]//[Type] [Name]//[Language]" "[URL]">

<!DOCTYPE> Parameters

Root element — a parent element that contains all the other elements. For HTML it is the <html> tag.

Publicity — the document can be PUBLIC or SYSTEM (local files, for example). For HTML/XHTML the value is PUBLIC.

Registration - can have two values: plus (+) - the developer is registered in ISO (International Organization for Standardization) and - (minus) - the developer is not registered. For W3C, the value is set to "-".

Organization — the name of DTD (Document Type Definition) developer. The developer of HTML/XHTML is W3C, and its name is declared in <!DOCTYPE>.

Type — the type of the document. For HTML/XHTML the value is DTD.

Name — unique identifier describing DTD.

Language — the language of the document (two letters in uppercase). For HTML/XHTML the language is English (EN).

URL — the URL of the document type description (e.g. http://www.w3.org/TR/html4/loose.dtd).

Types of <!DOCTYPE> Declaration

There are three types of <!DOCTYPE> declaration:

Strict - contains all HTML elements and attributes, but does not include presentational or deprecated elements.

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

Transitional - contains all HTML elements and attributes, including presentational and deprecated elements. Frames are not allowed.

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

Frameset - is equal to Transitional, but allows the use of frames.

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

There is only one version of declaration for HTML 5.

<!DOCTYPE html>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>The !DOCTYPE Declaration</title>
  </head>
  <body>
    <p>Paragraph</p>
  </body>
</html>

Result

Browser support