FactorPad
Faster Learning Tutorials

HTML DOCTYPE declaration

The first line in the HTML file lets the browser know what document type to expect.
  1. About - Understand the purpose of the DOCTYPE declaration.
  2. Syntax - Describe how it is used.
  3. Settings - View required and optional attributes plus default behaviors.
  4. Examples - Review common examples.
by Paul Alan Davis, December 26, 2017
Updated: August 9, 2018
Our overall focus is on HTML5, but here we touch on XHTML.

Outline Back Next

~/ home  / tech  / html5  / reference  / html doctype declaration


HTML DOCTYPE declaration with examples

Beginner

The !DOCTYPE declaration is one of several required lines at the beginning of an HTML document.

HTML Tags Reference

1. About the DOCTYPE declaration

The !DOCTYPE declaration instructs the browser as to what document type and version to expect, so it knows how to render the content. It must be present at the beginning of the document.

2. Syntax for the DOCTYPE declaration

The !DOCTYPE declaration is self-closing and does not require an ending tag.

The !DOCTYPE declaration is case insensitive, so it can also be input as !doctype and includes the type of document. In this case we are referring to HTML5, so we use html as the document type, which is also case-insensitive. The following is the most common format.

<!DOCTYPE html>

In a more strict markup called XHTML, both DOCTYPE and html are case-sensitive.

3. Settings for the DOCTYPE declaration

The !DOCTYPE declaration is specified uniquely for each of several HTML and XHTML versions, as listed below.

Version Format
HTML 5 <!DOCTYPE html>
HTML 4.01 <!DOCTYPE html PUBLIC "-//W3C/DTD HTML 4.01//EN">
HTML 4.0 <!DOCTYPE html PUBLIC "-//W3C/DTD HTML 4.0//EN">
XHTML 1.1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

4. Examples of the DOCTYPE declaration

Example 1 - Enter the DOCTYPE for HTML5

The following !DOCTYPE declaration is valid (and most common) for HTML5.

<!DOCTYPE html>
Example 2 - Enter the DOCTYPE for HTML5 using alternative capitalizations

Due to case-insensitivity in HTML5, the following is also correct, but less common.

<!doctype HTML>

Other Related HTML Content

The !DOCTYPE declaration is paired with other essential tags that should be included in every HTML document.


What's Next?

Our growing YouTube Channel offers other helpful and free ways to learn. Subscribe here.

  • For the complete HTML tags list, click Outline.
  • To learn about this HTML reference, click Back.
  • See how the <!-- comment --> tag works. Click Next.

Outline Back Next

~/ home  / tech  / html5  / reference  / html doctype declaration



 
 
Keywords:
doctype html
html doctype declaration
xhtml doctype
html5 doctype
html5 declaration
html declaration
doctype case sensitive
doctype case insensitive
doctype examples
doctype reference