Doctype and the basics of a valid document
A missing doctype throws browsers into quirks mode with 1990s layout rules. Start every page with <!doctype html>.
Step by step, with screenshots: HTML validation errors: which ones matter and which are noise →
Check your own site
Runs this check and the other 192, free, in about 45 seconds.
What it is
The doctype is the first line of an HTML document, <!doctype html>, and it tells the browser to render the page in standards mode, following the current HTML and CSS rules. It is not a tag and has no closing part; for HTML5 it is always this one short line.
Without it, browsers switch to quirks mode, which imitates the layout bugs of late-1990s browsers for compatibility with very old pages. Box sizes, table layout and some CSS behave differently, so the page can look different from browser to browser and from what your developer tested.
OK looks like this: <!doctype html> as the very first line of every page, before any whitespace, comment or byte-order issue pushes it down. getReport checks that the doctype is present.
What a passing site looks like
- Doctype is presentwarning · −1 ptseffort S
Doctype is missing
Why it matters. Without <!doctype html>, browsers render in quirks mode and layouts can differ between browsers.
- Put <!doctype html> as the very first line of the document.
Questions people ask
What is doctype html?
<!doctype html> is the document type declaration for HTML5. It sits on the first line of a page and tells the browser to use standards mode. Letter case does not matter, and older, longer doctypes for HTML 4 or XHTML are no longer needed; this short form works in every browser.
What is the doctype declaration in HTML?
It is an instruction at the start of an HTML document that tells the browser which rendering mode to use. In current HTML it is only <!doctype html>. Older HTML versions used long declarations that pointed to a DTD file, which browsers never actually downloaded.
What is quirks mode?
Quirks mode is a rendering mode browsers use for pages without a proper doctype. It imitates old browser bugs, for example a different box model and table sizing, so that very old websites still display as intended. Modern pages should always trigger standards mode with <!doctype html>.
Do you need doctype html?
Yes. Without it the page renders in quirks mode, and layout and CSS can differ between browsers in hard-to-debug ways. It costs one line, and validators and accessibility tools also report its absence. Put it before anything else in the file, even comments.