Page language
lang and xml:lang must agree
- Rule:
html-xml-lang-mismatch - Severity: Moderate
- WCAG level A
Why it matters
When the two attributes name different languages, the browser and the assistive technology can pick different ones, so the page may be read in a language it is not written in.
How to fix it
- Make both attributes carry the same language.
- In HTML you can simply drop xml:lang — it is only needed in XHTML served as XML.
In markup
<html lang="en" xml:lang="fr"><html lang="en" xml:lang="en">The requirement behind it
This rule is one way of failing the following WCAG 2.2 success criteria. The W3C, which writes the standard, explains each of them:
- 3.1.1 Language of Page (opens in new tab) — WCAG level A
Further reading
Deque University on html-xml-lang-mismatch (opens in new tab)
Deque maintains axe-core, the open-source engine our scanner runs. Their page documents the rule as the engine implements it.
Automated checks find failures a browser can prove. They cannot judge whether a caption is accurate, whether an alt text is useful, or whether a page can be operated end to end with a keyboard — those need a person.