xml:lang attributes of an element must have the same value.
Why it matters
When a web page’s primary language is programmatically identified, browsers and assistive technologies can render the text more accurately; screen readers can use the correct pronunciation; visual browsers can display the correct characters; and media players can show captions correctly. All users find it easier to understand the page’s content.
All HTML web pages must have a
lang attribute on the
<html> element and additional
lang attributes on any elements whose content is in a different language.
XHTML web pages and polyglot pages must also provide
xml:lang attributes on those same elements.
When a single element has both
xml:lang attributes, the two values must match exactly.
When the two attributes have different values, the user experience is unpredictable.
How to fix
For XHTML 1.x pages, or polyglot pages served as text/html:
- Use both the
langattribute and the
xml:langattribute each time you specify the language.
- Provide identical values for both attributes.
lang attribute correctly identifies the primary language as Spanish, but its
xml:lang attribute identifies it as English.
lang attribute and the
xml:lang attribute correctly identify the primary language of the page as Spanish.
Screen reader users find the content easier to understand because it's pronounced correctly.
About this rule
This rule passes if:
xml:langattributes have identical values