Skip to main content
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

missing-lang-attribute

Rule Severity : Serious

Description

Add a correct lang attribute for any language change within your content. This ensures assistive technologies, such as screen readers, can switch to the correct pronunciation and translation. Correctly identifying language changes is essential for users who rely on these tools to understand your content.

The missing-lang-attribute rule aligns with WCAG Success Criterion 3.1.2 (Language of Parts). This criterion requires that the human language of a passage or phrase is programmatically determinable.

Examples

The following example shows text with a French phrase that is not marked with a lang attribute. This violates the missing-lang-attribute rule because assistive technologies will not know to pronounce “Bonjour” correctly.

Incorrect Sample
Copy icon Copy

The following corrected example uses a element with the lang=”fr” attribute to mark the French word. This ensures that assistive technologies can correctly identify and pronounce the language change.

Correct Sample
Copy icon Copy

How to fix?

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

  • Identify content in a language different from the document’s primary language.

  • Wrap the text in an appropriate element, such as a <span> or <blockquote>.

  • Add a lang attribute to the element. The attribute’s value must be an ISO 639-1 language code, such as en for English or fr for French.

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