Skip to main content
HTML Validation

Using the “meta” element to specify the document-wide default language is obsolete. Consider specifying the language on the root element instead.

About This HTML Issue

In older HTML practices, developers sometimes used <meta http-equiv="Content-Language" content="en"> inside the <head> to declare the document’s primary language. The HTML living standard now marks this as obsolete because it was an unreliable and indirect way to communicate language information. It attempted to mirror an HTTP header rather than being a true part of the document structure, and its behavior was inconsistently implemented across browsers.

The lang attribute on the <html> element is the correct modern approach. It directly associates the language with the document’s DOM tree, which has several important benefits:

  • Accessibility: Screen readers rely on the lang attribute to select the correct pronunciation rules and voice profile. Without it, assistive technology may mispronounce content or fall back to a default language that doesn’t match the text.
  • Browser behavior: Browsers use the lang attribute to make decisions about hyphenation, font selection, quotation mark styling, spell-checking, and other language-sensitive rendering.
  • Search engines: Declaring the language helps search engines index and serve content to the appropriate audience.
  • CSS targeting: The :lang() pseudo-class selector works based on the lang attribute, enabling language-specific styling.

The lang attribute also supports granular, element-level language declarations. If your page is primarily in English but contains a French quote, you can set lang="fr" on that specific element — something the <meta> approach could never do.

Examples

Incorrect: using the obsolete meta tag

This triggers the W3C validation warning because <meta http-equiv="Content-Language"> is obsolete for specifying the document language.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Language" content="en">
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

Correct: using the lang attribute on <html>

Remove the <meta http-equiv="Content-Language"> tag and add the lang attribute to the <html> element instead.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

Correct: mixed-language content

Use the lang attribute on the root element for the primary language, then override it on specific elements as needed.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Multilingual Page</title>
  </head>
  <body>
    <p>The French word for hello is <span lang="fr">bonjour</span>.</p>
    <blockquote lang="de">
      <p>Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt.</p>
    </blockquote>
  </body>
</html>

Common language codes

Use a valid BCP 47 language tag as the value of the lang attribute. Here are some frequently used codes:

Code Language
en English
fr French
de German
es Spanish
pt-BR Brazilian Portuguese
zh-Hans Simplified Chinese
ja Japanese

The fix is straightforward: remove any <meta http-equiv="Content-Language"> tags from your <head> and ensure your <html> element includes a lang attribute with the appropriate language code. This single change resolves the validation warning while improving your document’s accessibility, rendering, and standards compliance.

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.