Rule
Page language
The <html> element must declare a valid language.
- Rule
html-lang- WCAG 2.2
- 3.1.1 Language of Page (opens in a new tab) (Level A)
- Severity
- Serious
What it checks
The rule reads the lang attribute on the <html> element. It fails when the attribute is missing, when it is empty, and when its value does not have the shape of a language tag, such as lang="english". Screen readers use this value to pick a voice and its pronunciation, so without it they guess.
A valid value is a language code of two or three letters, with optional further parts such as a region or a script: en, en-GB, zh-Hans. The rule checks the shape of the tag; it does not look each part up in the registry of languages. A document with no words at all, such as an empty frame a script has yet to fill, passes, because it has no language to declare.
Example
Fails
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Opening times</title>
</head>
<body>
<p>The library opens at nine.</p>
</body>
</html>
Passes
<!doctype html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<title>Opening times</title>
</head>
<body>
<p>The library opens at nine.</p>
</body>
</html>
The engine is tested against both examples.
How to fix it
Add a lang attribute to the <html> element with the main language of the page, such as lang="en" or lang="en-GB".
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.