Rule
Part language tags
lang attributes on page parts must be valid.
- Rule
valid-lang-parts- WCAG 2.2
- 3.1.2 Language of Parts (opens in a new tab) (Level AA)
- Severity
- Serious
What it checks
The rule reads every lang attribute below the <html> element. It fails when a value does not have the shape of a language tag and some text takes its language from that element. A screen reader may then read the passage with the wrong pronunciation, and browsers and translation tools may hyphenate or translate it wrongly.
An empty lang="" passes, because it hands the passage back to the language of the page. An invalid tag that governs no words passes too: an empty element, text that is not displayed, or a section where every word sits under another, valid lang. Words include spoken labels such as alt and aria-label, and text under aria-hidden="true" still counts where it can be seen.
Example
Fails
<p>The French for thank you is <span lang="french">merci</span>.</p>
Passes
<p>The French for thank you is <span lang="fr">merci</span>.</p>
The engine is tested against both examples.
How to fix it
Give the passage a valid language tag, such as lang="fr" or lang="de-AT".
Check your own pages
This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.