Rule ID: ace-meta-valid-lang

Validate that lang attribute values used within the page are recognized BCP 47 language tags

WCAG 2.0 (AA) - WCAG 2.2 (AA) 3.1.2: Language of Parts Blind Deafblind Cognitive Legal Risk

What This Rule Checks

The lang attribute in HTML defines the language of the document or a specific element, which helps assistive technologies, like screen readers, pronounce words correctly and tailor the interface for multilingual content. It is essential that the value of the lang attribute adheres to the BCP 47 language standard. Using an invalid or incorrect language code can lead to incorrect pronunciations, misunderstandings, and accessibility issues for users who rely on screen readers.

Who Is Affected

This issue primarily affects: Blind users, who rely entirely on screen readers or braille displays to navigate and interact with content; Deafblind users, who rely on braille displays and cannot access visual or auditory content; Cognitive users, who benefit from clear structure, simple language, and consistent navigation patterns.

Why This Matters

Invalid lang attributes within the page affect screen reader pronunciation for specific sections. A French phrase marked with an invalid code won’t trigger the French speech synthesizer, causing mispronunciation.

How to Fix

Ensure the lang attribute is present in the <html> tag or on relevant elements within the page.

The value of the lang attribute must be a valid BCP 47 language code.

For example:

  • en for English
  • fr for French
  • es for Spanish

If the language of the content changes within the document, make sure to specify it using the lang attribute for those specific sections.

Code Examples

Incorrect Markup Solutions:
Code example
<!-- Invalid lang attribute on element --> <p lang="french">Bonjour le monde</p> Copy
Correct Markup Solutions:
Code example
<!-- Valid BCP 47 language code --> <p lang="fr">Bonjour le monde</p> Copy

Common Mistakes to Avoid

  • Using full language names instead of BCP 47 codes.
  • Not marking up foreign language phrases within predominantly English content.
  • Using language codes that don’t match the actual content language.

Tip: Page-level metadata and settings affect the entire browsing experience. Language declarations, viewport settings, and page titles are foundational to accessibility and affect every user on every page load.

Related WCAG Criteria

  • 3.1.2: Language of Parts