HTML <!DOCTYPE> declaration

The <!DOCTYPE> declaration defines the HTML version of the page. The browser needs this information to know how to interpret the HTML. This declaration must appear on the first line of the document.

HTML Tag

Example

#

A <!DOCTYPE> that specifies the page uses the HTML5 version.

<!DOCTYPE html>
doctype = document type

Using <!DOCTYPE>

<!DOCTYPE> tells the browser which HTML version the page is using.

A web page must start with a <!DOCTYPE> declaration on the first line.

More Examples

An outline of an HTML5 page, starting with !DOCTYPE.

<!DOCTYPE html>
<html>

 <head>
  <title>Page title goes here</title>
 </head>

 <body>
   <!-- Page content goes here -->
 </body>

</html>

Note: For HTML5 the DOCTYPE declaration is <!DOCTYPE html>.


Common <!DOCTYPE> declarations

Next are <!DOCTYPE> declarations for different HTML versions.
The older versions are rarely used, but browsers continue to support these.


HTML 5

!DOCTYPE for HTML5 is simple, because DTD (type definitions) has been withdrawn from HTML5.

  <!DOCTYPE html>

HTML 4.01 Strict

This declaration includes all HTML elements and attributes, but not the deprecated ones, such as <font> and <plaintext>. Framesets are not allowed (framesets are panes that each load their own page)

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

HTML 4.01 Transitional

This declaration contains all HTML elements and attributes, including the deprecated ones, like <font>, <plaintext>, and <marquee>. Framesets are not allowed.

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

HTML 4.01 Frameset

This declaration is equal to HTML 4.01 Transitional, but it allows the use of framesets.

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

XHTML 1.0 Strict

This declaration contains all HTML elements and attributes, without the ones that are deprecated, like <font> and <plaintext>. Framesets are not allowed. Markup must be well-formed XML.

  <!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 declaration contains all HTML elements and attributes, including the deprecated ones, like <font> and <center>. Framesets are not allowed. Markup must be well-formed XML.

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

XHTML 1.0 Frameset

This declaration is equal to XHTML 1.0 Transitional, but it allows the use of framesets.

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

XHTML 1.1

This declaration is equal to XHTML 1.0 Strict. It allows adding modules (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">

Page Tags

The <!DOCTYPE> tag is part of a group of tags that define the structure of a web page. This group is referred to as the Page tag group. Together, these tags allow you to create solid, well-structured web pages.

Here is the complete list.

Element Description
<!DOCTYPE> Must appear on the first line of a page. Specifies the HTML version
<html> Defines the root container for an HTML document
<head> Creates a head container that holds page-level metadata elements
<meta> Provides metadata about a web page
<link> Defines a link to an external source, such as a style sheet
<base> Sets the base URL for all relative URLs on a page
<script> Adds JavaScript to a page. Either client- or server-side
<style> Adds CSS style elements to a page
<title> Specifies the page title that displays in the browser's tab
<body> Specifies a container for the content of the page, with text, links, images, etc.

Browser support

Here is when <!DOCTYPE> support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

Guides