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 webpages 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>.

(click on the image to open in a new tab)

The doctype declaration in HTML5 is NOT case-sensitive.

Any of the following three options will work.

  1. <!DOCTYPE html>
  2. <!DOCTYPE HTML>
  3. <!doctype html>

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

Privacy Policy Lambros Hatzinikolaou © 2024 — Today. All rights reserved.