What is the correct doctype declaration for a HTML5 document?

The first line of code we write in every HTML document is the DOCTYPE declaration.

DOCTYPE declarations link web pages to DTDs, document type definition, informing the browser about the HTML version that is being used on the web page.

A DTD defines what components we can use for building an HTML document.

Adhering to its rules, we can only use a list of verified elements and attributes.

Using the HTML5 DOCTYPE, the syntax is <!DOCTYPE html>.

Example of HTML5 code using the DOCTYPE declaration

The doctype declaration in HTML5 is NOT case-sensitive.

Any of the following three options will work.

  • <!DOCTYPE html>
  • <!DOCTYPE HTML>
  • <!doctype html>

    Although my blog doesn’t support comments, feel free to reply via email or X.