Skip to main content
HTML Validation

This document appears to be written in English but the “html” start tag has X

About This HTML Issue

The lang attribute on the <html> element declares the primary language of the document. The W3C validator uses heuristics to analyze the text content of your page, and when it detects a mismatch between the declared language and the apparent language, it raises this warning. For example, if your page content is written in English but lang="fr" (French) is set, the validator will flag this inconsistency.

Why This Matters

The lang attribute plays a critical role in several areas:

  • Accessibility: Screen readers use the lang attribute to select the correct pronunciation rules and voice profile. If a page is written in English but declares French, a screen reader may attempt to read the content with French pronunciation, making it unintelligible to the user.
  • Search engines: Search engines use the lang attribute to understand what language a page is in, which affects how the page is indexed and served in search results for different regions.
  • Browser features: Browsers rely on the lang attribute for built-in translation prompts, spell-checking, hyphenation, and font selection. An incorrect value can cause unexpected behavior in all of these areas.

How to Fix It

  1. Identify the primary language of your content. Look at the actual text on your page — what language is the majority of it written in?
  2. Update the lang attribute to the correct BCP 47 language tag for that language (e.g., en for English, fr for French, es for Spanish).
  3. If the lang attribute is already correct and the validator’s heuristic is wrong (e.g., your page genuinely is in another language but contains some English text or code), you can safely ignore this warning.

For pages with mixed-language content, set the lang attribute on <html> to the primary language, then use lang attributes on specific elements to mark sections in other languages.

Examples

❌ Incorrect: Content is in English but lang declares French

<!DOCTYPE html>
<html lang="fr">
  <head>
    <title>My Website</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
    <p>This is an English paragraph about web development.</p>
  </body>
</html>

The validator detects that the content is English, but lang="fr" says it’s French.

✅ Fixed: lang attribute matches the content language

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Website</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
    <p>This is an English paragraph about web development.</p>
  </body>
</html>

✅ Mixed-language content with proper lang attributes

If your page is primarily in English but contains sections in another language, set the document language to en and annotate the foreign-language sections individually:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Language Examples</title>
  </head>
  <body>
    <h1>Welcome</h1>
    <p>This page is mostly in English.</p>
    <blockquote lang="fr">
      <p>Ceci est une citation en français.</p>
    </blockquote>
  </body>
</html>

This approach ensures screen readers switch pronunciation only for the French <blockquote>, while the rest of the page is correctly read as English.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your free trial today.