These docs are for CORA 0.10, an older release. Read this page in the newest docs.
The lang and xml:lang attributes need to match
- Rule:
axe/html-xml-lang-mismatch - Checks: HTML elements with lang and xml:lang must have the same base language
- WCAG: 3.1.1
- Fix class:
mechanical: A fix needs no authored text or visual decision.
Who it affects
Section titled “Who it affects”- People who use a screen reader or a braille display, most of them blind.
- People with cognitive, learning or attention disabilities.
How to fix it
Section titled “How to fix it”The lang and xml:lang on <html> name different languages
Section titled “The lang and xml:lang on <html> name different languages”Find the one that matches the page’s content and set both to it. In a page served as HTML, xml:lang has no effect, so you can remove it and keep lang.
A script that switches the page language updates only one of them
Section titled “A script that switches the page language updates only one of them”Update both. If the page is served only as HTML, you can remove xml:lang instead, leaving one attribute to keep current.
Fixes that fail
Section titled “Fixes that fail”Copying one value onto the other without checking the content
Section titled “Copying one value onto the other without checking the content”The two then agree, but if the copied value was the stale one, screen readers read the page in the wrong language.
More on the rule
Section titled “More on the rule”axe-core’s documentation of the rule
CORA’s fix guidance adapts content from accessibility-agents, under the MIT License: see its notice.