missing-lang-attribute
Rule Severity : Minor
Description
Ensure that a lang
attribute is added to identify a change in language, whenever such a change occurs within the content. Missing language attributes can cause screen readers and other assistive technologies to misinterpret pronunciation or language-specific rendering.
The missing-lang-attribute
rule aligns with WCAG Success Criterion 3.1.2 (Language of Parts), which requires that the human language of content passages must be programmatically determinable.
Examples
In the following example, a paragraph in French lacks a lang
attribute, making it difficult for assistive technologies to interpret correctly.
In the corrected example, the lang attribute is added to specify the language change:
How to fix?
To fix violations of the missing-lang-attribute
rule, follow these steps:
- Identify text passages in a different language than the document’s primary language. The primary language of a page is the language that is used the most in the page. It must also be annotated in the
<html>
tag of the page using thelang
attribute. - Add a
lang
attribute with the correct language code to the containing element. - For nested language changes, ensure the inner
lang
attribute overrides the outer one wherever necessary.
Reference
WCAG Success Criterion 3.1.2: Language of Parts
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!