Skip to content
English
  • There are no suggestions because the search field is empty.

A: < html> element must have a valid value for the lang attribute (WCAG 3.1.1)

html-lang-valid

Ensure that the lang attribute of the <html> element contains a valid BCP-47 language code.

This means

The root element <html> needs a lang attribute with a valid language code such as dede-DEen-GB. Empty values, fictitious values, or incorrect spelling (for example underscore instead of hyphen) are not allowed.

Impact

With invalid or missing language settings, content is pronounced incorrectly, spelling and hyphenation do not fit, and users lose orientation. Additionally, the risk of a WCAG violation increases.

Recommendation

  • Set the main language of the page on <html>, for example lang="de" or lang="de-DE".

  • Observe BCP-47 rules: language part lowercase, region part uppercase, hyphen as separator (de-DE, not de_DE).

  • Do not use lists or placeholders (lang="de,en" or lang="xx" is invalid).

  • For multilingual sections also set lang on the respective element.

  • Keep the attribute up to date for dynamic language switching.

Example

Problematic

<!doctype html>
<html lang="">
  <head><title>Contact</title></head>
  <body>Welcome</body>
</html>
 
<html lang="de_DE"></html>   <!-- Underscore instead of hyphen -->
<html lang="german"></html>  <!-- Language name instead of code -->
<html lang="xx"></html>      <!-- invalid code -->

Better

<!doctype html>
<html lang="de">
  <head><meta charset="utf-8"><title>Contact</title></head>
  <body>
    <p>Welcome to our page.</p>
    <blockquote lang="en">Accessibility improves everyone’s experience.</blockquote>
  </body>
</html>
 
<!-- Variant with region -->
<html lang="de-DE"></html>

Related WCAG criterion:
WCAG 3.1.1 - Language of Page