html-xml-lang-mismatch
Description
When both the lang and xml:lang attributes are present on the <html> element, they must specify the same primary language. The xml:lang attribute is used in XHTML documents while lang is used in HTML. If they specify different languages, screen readers that process both attributes may encounter conflicting instructions about how to pronounce the page content.
Example
In the following example, lang is set to "en" (English) while xml:lang is set to "fr" (French). Screen readers may use one value or the other, leading to incorrect pronunciation of the page content. This breaks the html-xml-lang-mismatch rule.
In contrast, the following code snippet sets both lang and xml:lang to the same value "en". Both attributes agree on the page language, and the code does not break the html-xml-lang-mismatch rule.
How to fix?
Check if your <html> element has both lang and xml:lang attributes. If so:
- Ensure both attributes use the same primary language subtag (for example, both set to
"en"or both set to"fr"). - For HTML5 documents that are not served as XHTML, you can safely remove the
xml:langattribute and keep onlylang.
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!