has a lang attribute with a known primary language tag; and
has a non-empty xml:lang attribute.
Expectation
For each test target, the values of the primary language subtags, if any exist, for the lang and xml:lang attributes are the same.
Background
This rule is only applicable to non-embedded HTML pages. HTML pages embedded into other documents, such as through iframe or object elements are not applicable because they are not web pages according to the definition in WCAG.
Assumptions
The language of the page can be set by other methods than the lang attribute, for example using HTTP headers or the meta element. These methods are not supported by all assistive technologies. This rule assumes that these other methods are insufficient to satisfying Success Criterion 3.1.1: Language of Page.
This rule assumes that user agents and assistive technologies can programmatically determine known primary language tags even if these do not conform to the RFC 5646 syntax.
The rule assumes that having lang and xml:lang attributes with matching primary language subtags but non-matching language tags overall, will not cause accessibility issues. This is not necessarily the case for all languages. One notable case is the language tags for Cantonese (zh-yue) and Mandarin (zh-cmn) where the primary language subtags match, but the extended language subtags don't. Such a case would not fail this rule, but could lead to accessibility issues.
Accessibility Support
Since most assistive technologies will consistently use lang over xml:lang when both are used, violation of this rule may not necessarily be a violation of WCAG 2. Only when there are inconsistencies between assistive technologies as to which attribute is used to determine the language does this lead to a violation of SC 3.1.1.