Level AAWCAG 2.2
3.1.2 Language of Parts
The human language of each passage or phrase can be programmatically determined.
Why it matters
Correct pronunciation
Screen readers switch language engines to read foreign-language passages with the right pronunciation.
Academic and technical documents
Especially important for documents that mix technical terms and quotations across multiple languages.
Braille conversion
Braille conversion rules differ by language, so correct language identification is required.
Machine translation
Prevents browser translators from re-translating text that is already in a foreign language.
Live demo
Marking parts in another language
No lang attribute on the English words
<p> This feature is experimental. See the documentation for more details. </p>
Screen reader output
The Japanese voice tries to read the English words
"This feature is experimental."
"See the documentation for more details."
Visible example
This feature is experimental See the documentation for more details.
When English text appears inside a Japanese page, add
lang="en" so screen readers can switch to the correct pronunciation engine.Persona perspective
Takahashi (45) — Low vision
I use a screen reader together with a magnifier. When reading tech blogs, English terms read in Japanese become 'dokumentashon' and I can't tell what word it is. With a lang declaration, it's pronounced correctly as 'documentation'.
Checkpoints
References
→ Related: 3.1.1 Language of Page