HTML Doctypes

Understanding the HTML5 Doctype

The Document Type Declaration (DOCTYPE) is a declaration that tells the web browser which version of the markup language is used to write a web page. It appears at the very top of the web page, before any other elements.

Every HTML document is required by the HTML specification (or standards) to have a valid Document Type Declaration (DFD) in order to display your web pages as intended.

In most HTML documents, the DOM is the first thing that is defined (even before <html> tags).

However, the DOM is not the HTML tag itself.

DOCTYPE for HTML5 are very concise and case-sensitive.

<!DOCTYPE html>

Doctypes used to be longer because HTML was based on SGML and required a DTD reference, but they are obsolete now.

In HTML5, only the standard mode is required to enable a doctype declaration.

To create a new HTML document, you can use the following HTML markup as a template.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><!-- Insert your title here --></title>
</head>
<body>
<!-- Insert your content here -->
</body>
</html>

Note: The doctype declaration represents a DTD. A DTD is an instruction that tells a web browser what version of markup language a page is in. The W3C publishes a DTD for all versions of HTML.

Tip: You must include a doctype declaration in your HTML document. You can also check your HTML for any markup or syntax errors using the W3C's Validator before publishing it to the web.