Skip to main content

DOCTYPE in HTML – What Is a Document Type Declaration?

A DOCTYPE declaration informs browsers about a document's type and version.

Example of an HTML Document with a Doctype Declaration

The <!DOCTYPE html> preamble in the snippet below tells web browsers that the page is an HTML5 document type.

<!DOCTYPE html>
<title>Your document's title</title>
<!-- Space for the documents's content such as <p>, <div>, and <img> elements -->

Note the following:

  • A <!DOCTYPE> declaration is not an HTML tag. It is a preamble for declaring information about a document to web browsers.
  • It is essential to declare your document type before defining other HTML elements.
  • The <!DOCTYPE> declaration is case-insensitive. So, browsers interpret <!DOCTYPE>, <!doctype>, <!Doctype>, and <!DocType> as equivalent document type declarations.
Join CodeSweetly's Substack