FactorPad
Build a Better Process

HTML DOCTYPE Declaration Reference and Examples

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.
face pic by Paul Alan Davis, CFA
Updated: February 23, 2021
Our overall focus is on HTML5, but here we will touch on XHTML.

Outline Back Tip Next

/ factorpad.com / tech / html5 / reference / html-doctype-declaration.html


An ad-free and cookie-free website.


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. For reminders, subscribe and follow before you get distracted.

Outline Back Tip Next

/ factorpad.com / tech / html5 / reference / html-doctype-declaration.html


html doctype
html doctype tag
doctype element
what is the doctype in html
html doctype reference
html doctype examples
how to use the doctype in html
doctype declaration
html doctype declaration

A newly-updated free resource. Connect and refer a friend today.