missing-doctype¶
Added in 0.2.9 · Related issues · View source
What it does¶
Checks for HTML documents that contain an <html> tag but no <!DOCTYPE html> declaration.
Why is this bad?¶
HTML5 requires a DOCTYPE declaration at the top of every document. Without it, browsers fall back to "quirks mode", which emulates legacy rendering bugs and applies different CSS box-model rules. The result is inconsistent layout across browsers and behaviour that is hard to debug.
The declaration must come before the <html> tag: one placed after it still leaves the
browser in quirks mode.
Files that extend another template are assumed to inherit the DOCTYPE from their parent and
are not flagged. Neither is a document whose <html> tag is preceded by a root-level {% %}
block, since the block may be the one emitting the DOCTYPE.
Example¶
Use instead: