Page language
Inline language codes must be valid
- Rule:
valid-lang - Severity: Serious
- WCAG level AA
Why it matters
A lang attribute on a phrase switches the screen reader’s pronunciation. An invalid code is ignored, so a quoted French sentence is read with English pronunciation rules.
How to fix it
- Use a valid BCP 47 tag on the element ("fr", "pt-BR").
- Mark only the passages that really change language.
In markup
<span lang="deutsch">Guten Tag</span><span lang="de">Guten Tag</span>The requirement behind it
This rule is one way of failing the following WCAG 2.2 success criteria. The W3C, which writes the standard, explains each of them:
- 3.1.2 Language of Parts (opens in new tab) — WCAG level AA
Further reading
Deque University on valid-lang (opens in new tab)
Deque maintains axe-core, the open-source engine our scanner runs. Their page documents the rule as the engine implements it.
Automated checks find failures a browser can prove. They cannot judge whether a caption is accurate, whether an alt text is useful, or whether a page can be operated end to end with a keyboard — those need a person.