Skip to main content
No Result Found

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.

Incorrect Sample
Copy icon Copy

In the corrected example, the lang attribute is added to specify the language change:

Correct Sample
Copy icon Copy

How to fix?

To fix violations of the missing-lang-attribute rule, follow these steps:

  1. 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 the lang attribute.
  2. Add a lang attribute with the correct language code to the containing element.
  3. 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





Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle