lang attributes on page content must be valid
When you mark part of a page as another language with lang, the value must be a valid language code, so screen readers switch to the right voice for that passage.
| Rule ID | valid-lang |
|---|---|
| Impact | Serious |
| Success criterion | 3.1.2 Language of Parts · AA |
| Standards | WCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549 |
| Fixed automatically |
Example
<p>Our chef's favourite dish is
<span lang="italian">risotto alla milanese</span>.
</p>The screen reader ignores "italian" and mangles the dish name with English pronunciation.
<p>Our chef's favourite dish is
<span lang="it">risotto alla milanese</span>.
</p>The screen reader switches to an Italian voice for the dish name, then back to English.
Why it matters
Pages often mix languages: a quote in French, a product name in Japanese, a language switcher listing "Español" and "Deutsch". Screen readers change voice and pronunciation when they meet a lang attribute, but only if they recognize the code. With an invalid value, the passage is read with the page's main voice and can become unintelligible.
This matters most for blind users and people who rely on text-to-speech because of dyslexia. Language switchers are a common case: if "Deutsch" is read in English, German speakers may not find their version of the site.
How to fix it
Use a standard language tag: a two- or three-letter language code, optionally followed by a hyphen and a region.
<blockquote lang="fr">
<p>La vie est trop courte pour boire du mauvais vin.</p>
</blockquote>
Language switchers. Mark each option with its own language:
<ul class="lang-switch">
<li><a href="/es/" lang="es" hreflang="es">Español</a></li>
<li><a href="/de/" lang="de" hreflang="de">Deutsch</a></li>
</ul>
Typical errors:
- Language names (
lang="spanish") →es - Underscores (
lang="pt_BR") →pt-BR - Country codes (
lang="jp") →ja - Empty or whitespace values left by a template. An empty
lang=""is allowed only when the language is truly unknown.
Content editors. Many editors have a language button or an attribute field. Teach editors to use codes, not names.
Mark only real changes of language. Loan words that are common in the page language ("café" in English) do not need lang.
Checklist
- Use language codes, never language names.
- Use hyphens before the region: pt-BR, not pt_BR.
- Mark each option in a language switcher with its lang.
- Mark only real changes of language.
How the check works
The check looks at every element except <html> that has a lang or xml:lang attribute and fails when the primary part of the value is not a known language code. It cannot tell whether a passage in another language is missing a lang attribute, or whether the code matches the text: review multilingual content manually.
Resources
- Understanding 3.1.2 Language of Parts W3C
- W3C ACT rule de46e4 W3C ACT
- Declaring language in HTML W3C i18n
Updated October 27, 2026