- Level
- AA
- Since
- WCAG 2.0
- Entries
- 4 / 193
3.1.2 Language of Parts
A passage in another language has to say so, for the same reason.
/ What it requires
When a page written in one language contains a passage or a phrase in another, the code has to mark where the language changes. In HTML the lang attribute goes on the element that holds the foreign text. A screen reader then switches voice for that passage and switches back afterwards. Without the mark, an English quotation on a Polish page is read with Polish pronunciation, which listeners often cannot decode. Braille displays rely on the same information.
The criterion names four exceptions: proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the vernacular of the surrounding text. So a brand name, or the word "weekend" in a Polish sentence, needs no markup. A full sentence, a quotation, a block of legal text or a link to another language version does need it. An attribute with an invalid value, or one that names the wrong language, fails as well.
/ How pages fail it
- An English quotation or abstract sits on a Polish page with no lang attribute on its element.
- The language switcher lists "Deutsch" and "Polski" as links, and neither link carries its own lang.
- A paragraph pasted from another document keeps lang="en" although the text inside has since been translated.
- A span carries a value that is not a language tag, such as lang="english".
- A page prints the same notice in two languages one after the other, and only the language of the page is declared.
/ How to check it yourself
- Read the page and note every passage that is not in the main language: quotations, foreign titles, legal clauses and the links of the language switcher.
- Inspect each one in the developer tools and look for a lang attribute on the element itself or on an ancestor below the html element.
- Search the source for lang= and check every value you find. It has to be a valid tag, and it has to match the text inside.
- Listen to those passages with a free screen reader such as NVDA and hear whether the voice changes.
/ How to fix it
- Wrap a foreign phrase in a span element with the right value, for example lang="en" around an English phrase.
- Put lang on the block element when the whole block is in another language: blockquote, p, li or section.
- In a language switcher, give each link the lang of its own label, for example lang="de" on the link that reads "Deutsch".
- Remove lang attributes left over from pasted content, or correct them to the language of the text they now hold.
- Where content is written in a CMS editor, use its language tool for foreign passages, so that the mark is stored with the text.
/ What our scanner checks
Two checks look at values, not text. HTML_CodeSniffer H58.1.Lang goes through every element below html with a lang attribute and reports a value that is not shaped like a language tag, and the axe rule valid-lang reports invalid lang values. Neither can find a foreign passage with no lang attribute, which is the usual failure, or tell whether a valid tag matches the text.
/ Who fails it, in our own measurements
| Body | Sector | Instances | Score |
|---|---|---|---|
| Uniwersytet Jagielloński | education · PL | 12 | 1 |
| Bundestag | government · DE | 1 | 10 |
| Seattle | city · US | 1 | 12 |
| Warszawa | city · PL | 1 | 20 |
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
Do I have to mark every foreign word with a lang attribute?
No. Proper names, technical terms, words whose language cannot be determined and words that have entered everyday use in the surrounding language are exempt. A company name or a borrowed word such as "weekend" stays as it is. Mark phrases, sentences and longer passages that a reader of the main language would recognise as being in another language.
How do I mark a change of language in HTML?
Add the lang attribute with the correct language tag to the element that contains the text. For a few words inside a sentence, use a span element with lang="en" or another code. For a whole quotation or paragraph, put the attribute on the blockquote or p element. Everything inside inherits the value until a nested element sets another one.
Is Language of Parts required for level AA?
Yes. 3.1.2 is a level AA criterion and has been part of WCAG since version 2.0, so it belongs to every AA audit. Its companion 3.1.1 Language of Page is level A. Automated tools cover it poorly, because software can validate a lang value and has no reliable way to notice that an unmarked sentence is in another language.
