Skip to main content
HTML Validation

This document appears to be written in English but the “html” start tag has an empty “lang” attribute. Consider using “lang="en"” (or variant) instead.

About This HTML Issue

The lang attribute on the <html> element declares the primary language of the document’s content. When this attribute is left empty (lang=""), it effectively tells browsers and assistive technologies that the language is unknown or intentionally unspecified — which is almost never what you want.

This matters for several important reasons:

  • Accessibility: Screen readers rely on the lang attribute to select the correct pronunciation engine. An empty value can cause a screen reader to fall back to a default language, potentially reading English text with incorrect pronunciation rules.
  • Search engines: Search engines use the lang attribute to understand what language your content is in, which helps serve your pages to the right audience.
  • Browser features: Browsers use the language declaration for hyphenation, spell-checking, font selection, and other language-sensitive rendering decisions.
  • Standards compliance: The WHATWG HTML living standard specifies that if the lang attribute is present, its value must be a valid BCP 47 language tag. An empty string is not a valid language tag.

The fix is straightforward: set the lang attribute to a valid BCP 47 language tag that matches your content. For English, common values include en (general English), en-US (American English), or en-GB (British English). If your content is in another language, use the appropriate tag (e.g., fr for French, de for German, ja for Japanese).

Examples

❌ Empty lang attribute (triggers the warning)

<!DOCTYPE html>
<html lang="">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
  </body>
</html>

❌ Missing lang attribute entirely

While a missing lang attribute triggers a different warning, it causes the same underlying problem — no language is declared:

<!DOCTYPE html>
<html>
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
  </body>
</html>

✅ Correct: specifying the language

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
  </body>
</html>

✅ Correct: using a regional variant

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome to my website</h1>
  </body>
</html>

Using lang for mixed-language content

If your document is primarily in English but contains sections in other languages, set lang="en" on the <html> element and override it on specific elements:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Multilingual Page</title>
  </head>
  <body>
    <h1>Welcome</h1>
    <p>This page contains a quote in French:</p>
    <blockquote lang="fr">
      <p>La vie est belle.</p>
    </blockquote>
  </body>
</html>

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.