What is a doctype?
A doctype, or document type declaration, is the first line of an HTML file. In modern HTML it is simply <!DOCTYPE html>. Its only practical job today is to tell the browser to render the page in standards mode, following current CSS and HTML specifications.
Without it, browsers switch to quirks mode, which imitates the behavior of browsers from the late 1990s so that very old pages still display. Quirks mode changes how the box model, table sizing, and some layout rules work, which can break a modern layout in subtle ways.
How it works
Browsers look at the very start of the document. If <!DOCTYPE html> is present, they use standards mode. If it is missing, malformed, or preceded by other content, they may fall back to quirks mode. Older doctypes, such as HTML 4.01 Transitional, can trigger "limited quirks" mode.
The declaration is case-insensitive, so <!doctype html> is equally valid. It is not an HTML tag and has no closing tag.
Search engines do not rank pages by doctype. The effect is indirect: a page rendered in quirks mode can show layout problems, overlapping elements, or mobile issues that hurt how Google's renderer and real visitors see it. Some validators and accessibility tools also report errors on documents without one.
Example
A minimal valid HTML5 document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pour-Over Guide</title>
</head>
<body>
<h1>Pour-Over Guide</h1>
</body>
</html>
The legacy HTML 4.01 version looked like this, and you may still see it on old sites:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
To check which mode a page is in, run document.compatMode in the browser console: CSS1Compat means standards mode, BackCompat means quirks mode.
In WordPress
The theme outputs the doctype, usually as the first line of header.php in classic themes or automatically in block themes. It goes missing most often when a plugin or functions.php prints whitespace, a byte-order mark, or a PHP warning before the doctype, which pushes it off the first line. The hydrogenseo.com bulk audit flags pages with no doctype.
Common mistakes
- Output before the doctype, such as debug notices or a UTF-8 byte-order mark saved at the top of a PHP file.
- Custom templates or landing page tools that emit HTML fragments without a doctype.
- Keeping a legacy doctype on an old theme.
Common questions
Does a missing doctype hurt SEO?
Not directly, but quirks mode can break layout and mobile rendering, which affects users and how Google renders the page.
Is <!DOCTYPE html> the right doctype for every page?
Yes. It is the HTML5 doctype and the only one new pages need.