html-lang-valid
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.
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.
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,
enfor English,frfor French,defor German). - For region-specific variants, combine the language and region subtags (for example,
en-USfor American English orzh-CNfor 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
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!