Skip to main content
🎉 A11y Issue Detection Agent is now live! Detect accessibility issues like a WCAG expert with AI. Try now!
No Result Found
Connect and get help from 7,000+ developers on our Discord community. Ask the CommunityAsk the Community

html-lang-valid

Severity: Serious

Description

The lang attribute on the <html> element must contain a valid BCP 47 language tag. Screen readers use this attribute to determine which language rules and pronunciation to apply when reading the page aloud. An invalid or misspelled language code means the screen reader may use incorrect pronunciation, making the content difficult to understand.

Example

In the following example, the lang attribute is set to "english", which is not a valid BCP 47 language tag. Screen readers cannot identify the language from this value, breaking the html-lang-valid rule.

Incorrect sample - invalid lang attribute value
Copy icon Copy

In contrast, the following code snippet uses the valid BCP 47 language tag "en" for English. Screen readers apply the correct language rules, and the code does not break the html-lang-valid rule.

Correct sample - valid lang attribute value
Copy icon Copy

How to fix?

Check if the lang attribute on your <html> element contains a valid BCP 47 language tag. If not:

  • Replace the invalid value with the correct two-letter ISO 639-1 language code (for example, en for English, fr for French, de for German).
  • For region-specific variants, combine the language and region subtags (for example, en-US for American English or zh-CN for Simplified Chinese).

Reference

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