Error Missing HTML5 doctype

Why a page needs <!DOCTYPE html> at the very top, and what quirks mode does to layout when it's missing.

The validator flags any document that does not start with <!DOCTYPE html> (case-insensitive, ignoring leading whitespace).

Why it happens

The doctype is a historical artifact from HTML 4 and XHTML, where it pointed to a DTD (Document Type Definition) the browser could validate against. HTML5 keeps the syntax purely as a signal — one line, no DTD reference — that tells the browser "render this in standards mode."

Example

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Page title</title>
  </head>
  <body>...</body>
</html>

Why it matters

Without a doctype (or with an old HTML4/XHTML doctype), browsers fall back to quirks mode — a legacy rendering mode that reproduces bugs from browsers of the late 1990s for backward compatibility. Quirks mode changes box-model sizing, table layout, and CSS unit handling in ways that are inconsistent across browsers. Standards mode, triggered by a bare <!DOCTYPE html>, is what every modern layout technique (flexbox, grid, box-sizing) assumes you're in.

Frequently asked questions

What is quirks mode?

A legacy rendering mode browsers fall back to when no valid doctype is present, replicating layout bugs from 1990s browsers for backward compatibility. It affects box-model sizing and table layout in ways that differ between browsers.

Does the doctype need attributes like HTML 4 did?

No. HTML5's doctype is exactly <!DOCTYPE html> with nothing else — no DTD URL, no XML namespace. Anything more elaborate is either an old HTML4/XHTML doctype (which triggers quirks or limited-quirks mode) or invalid.