valid-lang
Web validation
lang attribute’s value must be a valid ISO 639 language tag.Sometimes pages contain content in more than one language. A lang attribute on a specific element tells browsers and assistive technology which language engine to load for it, so text is pronounced and parsed correctly. An invalid tag such as lang="english" falls outside the ISO 639 list and cannot be interpreted reliably. When language metadata is wrong or missing, assistive technology may misread the content of the element, confusing people who rely on speech output.
Pass Patterns
A page in English with a specific part that is written in Spanish
The document’s root element uses the two-letter tag en, and the Spanish phrase is correctly marked with lang="es". Both tags appear in ISO 639-1.
<!DOCTYPE html>
<html lang="en">
<head>…</head>
<body>
<p>Welcome!</p>
<p lang="es">¡Hola!</p>
</body>
</html>Specifying a dialect
fr-CA on the second paragraph identifies Canadian French, a valid subtag combination that helps screen readers switch voices automatically.
<!DOCTYPE html>
<html lang="en">
<head>…</head>
<body>
<p>Hello world!</p>
<p lang="fr-CA">Bonjour tout le monde!</p>
</body>
</html>Fail Patterns
Invalid dialect subtag separator
The separator between the language tag and its dialect subtag must be a hyphen (-). Using an underscore makes the language tag invalid.
<!DOCTYPE html>
<html lang="fr">
<head>…</head>
<body>
<p>Bonjour tout le monde!</p>
<p lang="en_GB">Hello world!</p>
</body>
</html>Invalid language value due to a nonexistent language tag
english is not an ISO 639 code, so the user agent cannot map it to a language engine.
<!DOCTYPE html>
<html lang="es">
<head>…</head>
<body>
<p>¡Hola!</p>
<p lang="english">Welcome!</p>
</body>
</html>ACT Rules
Try It Yourself
Screen readers read and pronounce text in different languages based not only on the lang attribute, but also on the installed language packages and the operating system’s default language. To ensure consistent test results across all users, the tests will focus on validating allowed lang values from Set 1 of the ISO 639 standard.
Inspecting the browser dev-tools
- Open the page in a browser.
- Open Developer Tools and switch to the Elements panel.
- Select the element with the specific
langattribute (not thehtmltag which defines the language of the entire page).
Expected result: The primary language subtag of the element’s lang value (for example, fr in fr-CA) is included in the ISO 639 list.
Actual result: The value of the element’s lang attribute is not included in the ISO 639 list.
FAQ
How does this issue relate to 3.1.2 Language of Parts?
SC 3.1.2 requires that each passage written in a different language be programmatically identified. Invalid or absent lang values break that linkage, so assistive technology cannot shift to the right pronunciation library.
Why is this issue marked as Serious?
Mislabeling language stops speech engines from switching voices, which can render entire passages unintelligible for screen-reader users and anyone who depends on text-to-speech. Because it blocks comprehension rather than merely slowing it, the impact is considered serious across major browsers and assistive technologies.
Standards and Regulations
| Standard | Success Criterion | Reference |
|---|---|---|
| WCAG 2.2 | 3.1.2 Language of Parts (AA) | The human language of each passage or phrase in the content can be programmatically determined, except for proper names, technical terms, words of indeterminate language, and words that have become part of the vernacular of the immediately surrounding text. |
| EN 301 549 | 9.3.1.2 Language of Parts | Same as the WCAG text. |