html-xml-lang-mismatch

lang and xml:lang must not disagree

automaticWCAG 3.1.1 (A)confidence: highseverity: seriousunderstandable

Checks that the <html> element's lang and xml:lang attributes declare the same primary language, when both are present.

Applies to. Applies when the <html> element has both a non-empty lang attribute whose primary language subtag is a known one (ACT 5b7ae0) and a non-empty xml:lang attribute that has a primary language subtag. A lang naming no known language is html-lang-attr-present's failure, not this rule's; an xml:lang with no primary subtag (a private-use "x-foo", or no tag at all) has no language to compare, as ACT's "if any exist" says.

Expectation. The primary language subtag (the part before the first "-") of lang and xml:lang match, case-insensitively. When both attributes are present but declare different languages, assistive technology and user agents may resolve the page's language inconsistently.

What a finding reports.

  • lang, xmlLang: the values of the lang and xml:lang attributes, as written.

These data.details fields help to read and reproduce a finding. Apart from reasonCode and the few fields Output schema names as stable, they are not a stable contract: a field may be renamed or dropped in a minor release, so don’t build on them.

Examples

pass
<html lang="en-US" xml:lang="en-GB">

Primary subtags agree (en); regional subtags are allowed to differ.

fail
<html lang="en" xml:lang="fr">

lang and xml:lang declare different primary languages.

View source