What This Means

HTML content or characters appear before the opening <html> element. A valid HTML document must begin with a DOCTYPE declaration followed immediately by the <html> element — nothing else should precede it.

Why It Matters for SEO

Content before the <html> tag forces the HTML parser to begin in body mode immediately, before a proper head is established. This commonly results in the entire head section being treated as body content — metadata elements being misinterpreted, the title not being recognized, canonical tags being in the wrong position, etc.

This is most commonly caused by: a BOM (byte order mark) before the DOCTYPE; PHP whitespace output before the opening <?php tag; or an output buffer flush before the HTML document starts.

What the Platform Checks

The platform checks for non-whitespace content before the <!DOCTYPE html> declaration or the <html> element. Fires when any such content is found.

How to Fix It

  • BOM issue: Save the file without a BOM (UTF-8 without BOM in your editor settings).
  • PHP whitespace: Ensure no whitespace appears before <?php on the first line of PHP files that output HTML. Use a strict linting rule.
  • Output buffering: Use ob_start() at the beginning of PHP output to capture any accidental output before the document starts.
  • Template includes: Review any includes that run before the main template — ensure they produce no output.

Find every pagewith content before html

The audit flags pages with content before the html element — a structural issue that can corrupt metadata parsing.