valid-lang
Element lang attribute must be syntactically valid
automaticWCAG 3.1.2 (AA)confidence: highseverity: moderateunderstandable
Checks that any element (other than the root <html>) with a non-empty lang attribute uses a syntactically valid language tag.
Applies to. Applies to any element other than the root <html> with a non-empty lang attribute AND at least some non-whitespace "governed text" that actually inherits its language from that element, per ACT de46e4:
- Descendant text/alt is governed by the nearest lang-carrying ancestor only, a nested descendant with its own non-empty lang re-scopes everything inside it, so that subtree no longer counts toward the outer element's applicability (it counts toward the nested element's own, if that one is also being evaluated).
- A non-empty alt attribute on img/area/input[type=image] counts as governed text, the same as a text node.
- Text (or alt) that CSS keeps out of the render tree (display:none, the hidden attribute, ...) does not count. aria-hidden and offscreen positioning do NOT exempt text, per ACT's own failed examples for both, only actual non-rendering does.
Expectation. The lang value matches a valid BCP47 language-tag syntax. WCAG 3.1.2 (Language of Parts) requires that when a passage's language differs from the page's default, it is identified programmatically. An invalid tag fails to identify a real language at all.
Examples
pass
<p lang="fr">Bonjour</p>
"fr" is a syntactically valid BCP 47 language tag.
fail
<p lang="xyz123!!">???</p>
The value isn't valid BCP 47 syntax.