Someone always asks it, usually with suspicion: “Why is <!DOCTYPE html> so short? Where is the DTD? My validator used to need a URL half a mile long.” The honest answer is delightful — the modern doctype is not really a document type declaration at all. It is a mode switch wearing an old costume.
In the late 1990s, browsers rendered pages with the box quirks and CSS bugs of their era. When standards-compliant rendering arrived, breaking every existing page overnight was unthinkable. So browsers adopted a compromise called doctype sniffing: look at the very top of the document and decide which set of rules to obey.
The old HTML 4 and XHTML doctypes were long precisely because they pointed at a formal DTD:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
HTML5 recognized the truth: browsers never actually fetched or validated against those DTDs. The only thing that mattered was presence and shape. So the specification defined the shortest string that reliably triggers standards mode in every browser:
<!DOCTYPE html>
That is the whole point. It is case-insensitive, it takes no DTD, and it exists purely to say “render me by the rules.” Anything shorter, misspelled, or missing drops you into quirks mode.
When a tool complains the doctype is unrecognized, it is almost always one of three things:
The doctype must be the first thing in the document. Not the second, not “near the top” — the first. HTML comments before it are permitted; blank lines and whitespace text are not always forgiven.
Do not guess. Open the console and ask:
document.compatMode
// "CSS1Compat" → standards mode
// "BackCompat" → quirks mode
If you see BackCompat, your layout math is running on 1998 rules and no amount of clever CSS will fully save you. Fix the top of the document first, then debug everything else — because in quirks mode, everything else is a moving target.