Skip to content

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.

Template partials (files with a root-level {% extends %} tag or {% block %} block) are assumed to inherit the DOCTYPE from their parent template and are not flagged.

Example

<html lang="en">
  <head><title>Page</title></head>
  <body>Content</body>
</html>

Use instead:

<!DOCTYPE html>
<html lang="en">
  <head><title>Page</title></head>
  <body>Content</body>
</html>

References