Skip to main content

Document Type HTML

Published on .

What is it?

<!DOCTYPE html> is an HTML5 (Hypertext Markup Language, version 5) doctype declaration. It is the first line of code in an HTML document. It tells web browsers which version of HTML is being used and how to interpret the following code. In this case, it tells web browsers that it is an HTML version 5 document.

Do you need to include it?

Yes, you must include it on every webpage.

Older HTML documents

The document type for the strict HTML 4.01:

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

The document type for the loose HTML 4.01:

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

The document type for the frameset HTML 4.01:

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

The document type for the XHTML 1.1:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Do not waste your time learning about those document types. Just use the HTML5 document type.

Resources

HTML Standard #the-doctype

Doctype - MDN Web Docs Glossary: Definitions of Web-related terms | MDN

Quirks Mode - HTML: HyperText Markup Language | MDN

What is the DOCTYPE Declaration in HTML?