Rampsight

All rules

Page language

lang and xml:lang must agree

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

  1. Make both attributes carry the same language.
  2. In HTML you can simply drop xml:lang — it is only needed in XHTML served as XML.

In markup

Fails
<html lang="en" xml:lang="fr">
Passes
<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:

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.