html-has-lang
Web validation
<html> element must include a valid lang attribute that reflects the page’s primary natural language.The lang attribute enables browsers and assistive technology to deliver correct pronunciation, spell-checking, and font selection. When it is missing or invalid, people who rely on screen readers can find the content confusing or unintelligible, and search engines may misclassify the page. Always provide a short, valid ISO 639 language tag (en, fr-CA, and so on) on every page.
Pass Patterns
<html> element with a lang attribute
The page declares the primary language with a valid tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>Fail Patterns
<html> element with no lang attribute
The page omits the lang attribute, so the language cannot be determined.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Missing lang</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>WCAG techniques
Sufficient techniques
- H57: Using the language attribute on the HTML element
- H58: Using language attributes to identify changes in the human language
ACT Rules
Try It Yourself
Inspecting the browser dev-tools
- Open the page in a browser.
- Open Developer Tools and switch to the Elements panel.
- Select the root
<html>element.
Expected result: The <html> element has a non-empty lang attribute.
Actual result: The <html>’s lang attribute is missing or empty.
FAQ
How does this issue relate to 3.1.1 Language of Page?
SC 3.1.1 requires that the default human language of each web page be programmatically determinable. Declaring lang on the <html> element meets this requirement by making the language explicit to user agents and assistive technology.
Why is this issue marked as Serious?
Misidentified language immediately affects comprehension for screen reader users and can hamper text-to-speech, translation, and search indexing. The fix is straightforward, but the impact on user experience is significant across browsers and assistive technology, so the severity is classified as Serious.
Standards and Regulations
| Standard | Success Criterion | Reference |
|---|---|---|
| WCAG 2.2 | 3.1.1 Language of Page (A) | The default human language of each web page can be programmatically determined. |
| EN 301 549 | 9.3.1.1 Language of Page | Same as the WCAG text. |