Skip to content

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.
  • People who use a screen reader or a braille display, most of them blind.
  • People with cognitive, learning or attention disabilities.

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.

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.

axe-core’s documentation of the rule

CORA’s fix guidance adapts content from accessibility-agents, under the MIT License: see its notice.