WCAG 2.2 - Success Criterion
3.1.1 Language of Page
Description
The default human language of each web page must be programmatically determinable. This is achieved by setting the lang attribute on the <html> element using a valid BCP 47 language tag (e.g., lang="en" for English or lang="fr" for French). Screen readers and other assistive technologies rely on this attribute to select the correct language profile for speech synthesis, Braille output, and other language-specific rendering.
How To Test
- View the page source or use browser developer tools to inspect the opening
<html>tag. - Confirm that a
langattribute is present on the<html>element. - Verify that the
langvalue is a valid BCP 47 language tag that matches the primary language of the page content. - Check that the
langvalue is not empty (e.g.,lang=""is a failure). - If using a screen reader (e.g., NVDA or JAWS), navigate through body text and listen for correct pronunciation consistent with the page language.
- Use an automated tool such as axe or WAVE to flag missing or invalid
langattributes.
Testing Tools
- NVDA — Free screen reader for Windows. Download, install, and open Firefox to test the demo. Navigate using Tab and arrow keys, and listen to role, name, and state announcements from the page.
- VoiceOver (macOS) — Built into macOS. Enable with Cmd+F5, then open Safari or Chrome to test the demo. Use VO+arrow keys to navigate and hear semantic structure announcements.
- Lighthouse — Browser accessibility audit in Chrome DevTools. Open DevTools (F12), go to Lighthouse, run the audit to identify semantic and labeling issues.
Demo 1: Missing Language Declaration
Without a lang attribute, the screen reader uses its default language profile. If that differs from the page language, all text is mispronounced.
<!-- Fail: no lang attribute -->
<html>
<!-- Fail: empty lang -->
<html lang="">
A valid BCP 47 language tag on <html> tells screen readers which speech synthesiser voice and pronunciation rules to use.
<!-- Pass: English -->
<html lang="en">
<!-- Pass: French -->
<html lang="fr">
<!-- Pass: region subtag is optional but acceptable -->
<html lang="en-US">
Code
Demo 2: Wrong Language Declared
The page content is in Spanish, but the HTML declares English. Screen readers will apply English pronunciation rules to Spanish words, making them unintelligible.
<!-- Fail: Spanish content with English lang -->
<html lang="en">
<body>
<h1>Bienvenido</h1>
<p>Esto es contenido en español.</p>
</body>
</html>
The page content is in Spanish and the HTML correctly declares Spanish. Screen readers apply Spanish pronunciation rules, making the content clear and intelligible.
<!-- Pass: Spanish content with Spanish lang -->
<html lang="es">
<body>
<h1>Bienvenido</h1>
<p>Esto es contenido en español.</p>
</body>
</html>
Code
Demo 3: Valid vs. Invalid Language Tags
Invalid language tags do not follow the BCP 47 standard. Browsers and screen readers may not recognize these values, falling back to default language settings.
<!-- Fail: Full language name (not BCP 47) -->
<html lang="English">
<!-- Fail: Incorrect formatting (hyphens, case) -->
<html lang="en-usa">
<!-- Fail: Empty attribute -->
<html lang="">
Valid BCP 47 language tags use ISO 639-1 codes with optional region subtags in uppercase. These are recognized by all browsers and assistive technologies.
<!-- Pass: Valid two-letter code -->
<html lang="en">
<!-- Pass: Valid code with region -->
<html lang="en-US">
<!-- Pass: Valid code for other languages -->
<html lang="fr">
<html lang="de-CH">
Code
Fail Explanation
A page that is missing the lang attribute on the <html> element, or that has an incorrect or empty lang value, will cause screen readers to default to whatever language the user has configured as their system default. If that language differs from the page's actual language, the screen reader will mispronounce words, apply incorrect phonetic rules, and deliver content that is unintelligible to users who rely on audio output.
Pass Explanation
A page passes when its <html> element carries a valid BCP 47 language tag that accurately reflects the primary language of the page content (e.g., <html lang="en">). This allows screen readers to automatically switch to the correct speech synthesizer voice and pronunciation rules, ensuring the content is rendered accurately for users of assistive technology.
Notes
The lang attribute must reflect the primary language of the page; pages that contain mixed-language content may also need to satisfy 3.1.2 Language of Parts for the secondary-language passages. A region subtag (e.g., lang="en-US") is optional but acceptable as long as the primary language subtag is correct.
Techniques
WCAG techniques used in this demo: H57