- Level
- A
- Since
- WCAG 2.0
- Entries
- 26 / 193
3.1.1 Language of Page
The page has to declare its language, or a screen reader reads Polish text with an English voice.
/ What it requires
Every page has to state, in its code, which human language it is written in. In HTML that is the lang attribute on the html element. A screen reader uses it to pick the voice and the pronunciation rules, so a Polish page marked as English, or not marked at all, is read out with English sounds and becomes hard to follow. The same attribute guides braille output, automatic hyphenation and the choice of quotation marks.
The page passes when the html element carries a valid language tag that matches the main language of the content, for example lang="pl" or lang="en-GB". An absent or empty attribute fails, and so does a value that is not a real language tag. The criterion names no exceptions. Where a page mixes languages, declare the one used most and mark the other passages separately, as 3.1.2 requires. A tag for the wrong language defeats the purpose even when it is well formed.
/ How pages fail it
- The html element has no lang attribute at all.
- A Polish or German site keeps lang="en" from the template it was built on.
- The value is not a language tag, such as lang="polish" or lang="pl_PL" with an underscore.
- The attribute is present and empty, written as lang="".
- Every language version of a multilingual site carries the same value, so the German pages are announced as English.
/ How to check it yourself
- Open the page source and look at the opening html tag near the top, which should carry a lang attribute.
- Alternatively type document.documentElement.lang into the browser console. An empty result means the attribute is missing.
- Check that the value is a real language tag: a short code such as pl, de or en, optionally followed by a hyphen and a region, as in en-GB.
- Compare the value with the language you actually read on the page, and repeat this for each language version of the site.
- Listen to a paragraph with a free screen reader such as NVDA. A wrong voice is audible at once.
/ How to fix it
- Add the attribute to the root element, for example lang="pl" on the html element of a Polish page.
- On a multilingual site, fill the value from the locale of each page in the template or in the language setting of the CMS, never as a fixed string.
- Write regional variants with a hyphen, as in en-GB or de-AT, and not with an underscore.
- In XHTML served as XML, add xml:lang with the same value next to lang.
- Do not rely on a meta tag with http-equiv="content-language", because assistive technology does not take the page language from it.
/ What our scanner checks
Four checks look for one fault, an html element with no language. Our html_lang_missing check reads the raw HTML, while lang-missing, the axe rule html-has-lang and HTML_CodeSniffer H57.2 read the rendered page. None compares the declared language with the words on the page. A fifth check filed here, charset_missing, reports a missing character encoding declaration, which this criterion does not require.
/ Who fails it, in our own measurements
| Body | Sector | Instances | Score |
|---|---|---|---|
| HealthCare.gov | health · US | 3 | 57 |
| Medicare | health · US | 3 | 51 |
| Łódź | city · PL | 3 | 3 |
| Federal Aviation Administration | transport · US | 2 | 14 |
| Kielce | city · PL | 2 | 71 |
| Miami-Dade County | government · US | 2 | 20 |
| Narodowy Bank Polski | government · PL | 2 | 23 |
| National Weather Service | government · US | 2 | 34 |
| New York Public Library | culture · US | 2 | 24 |
| Social Security Administration | government · US | 2 | - |
| Sąd Najwyższy | government · PL | 2 | 14 |
| Dallas | city · US | 1 | 23 |
| Gorzów Wielkopolski | city · PL | 1 | 6 |
| Humboldt-Universität zu Berlin | education · DE | 1 | 35 |
| Instytut Pamięci Narodowej | government · PL | 1 | 43 |
| Kraków | city · PL | 1 | 12 |
| Las Vegas | city · US | 1 | 8 |
| Najwyższa Izba Kontroli | government · PL | 1 | 41 |
| Narodowy Instytut Zdrowia Publicznego | health · PL | 1 | 25 |
| New York City | city · US | 1 | 37 |
| Rzeszów | city · PL | 1 | 8 |
| Seattle | city · US | 1 | 12 |
| Sejm RP | government · PL | 1 | 9 |
| Universität Heidelberg | education · DE | 1 | 21 |
| Uniwersytet Łódzki | education · PL | 1 | 9 |
| Zarząd Transportu Miejskiego Warszawa | transport · PL | 1 | 77 |
One page per body, measured by automated checks on a weekly schedule. Any body that has fixed something since the last sweep will show it at the next one, and every entity page carries a right of reply.
/ Questions about this criterion
What lang attribute should a Polish or German page have?
Put the two-letter code of the language on the html element: lang="pl" for Polish, lang="de" for German, lang="en" for English. A region can follow after a hyphen where it matters, as in de-AT or en-GB. The codes come from the IANA language subtag registry, which is the list that browsers and screen readers understand.
What happens if the lang attribute is missing?
A screen reader falls back to its default voice, usually the language of the operating system or the one it used last. Text in another language is then pronounced by the wrong rules and can be unintelligible. Browser features that depend on the language, such as automatic hyphenation, may also stop working on that page.
Is lang="en" on a page that is not in English a WCAG failure?
In practice, yes. The criterion asks that software can determine the default language of the page, and a tag naming another language gives software the wrong answer. Many automated checkers only confirm that the attribute exists and is well formed, so this mistake passes them unnoticed. It takes a person reading the page, or a screen reader, to catch it.
