SIA-R6<html> document elements have matching lang and xml:lang attributes (DEPRECATED)
Accessibility requirements
This rule tests conformance of the following accessibility requirements:
Modern screen readers do not rely on the xml:lang attribute anymore, when a lang attribute is given, and discrepancies between these do not cause problem anymore. Therefore this rule has been deprecated and shouldn't be used.
Description
This rule checks that for document elements with both a lang and xml:lang attribute, the primary language subtags of the attributes match.
Applicability
This rule applies to every document element if it is an <html> element in the HTML namespace that:
- is in a top-level browsing context; and
- has a
langattribute that has a valid primary language subtag; and - has an
xml:langattribute.
Expectations
-
The primary language subtags, if any exist, of the
langandxml:langattributes are equal.HTML requires that the
langandxml:langattributes match exactly. There is however no known accessibility issue of having mismatching extended language subtags, hence this is permitted by this rule.
Assumptions
This rule makes the following assumption:
- The
langattribute is being used to conform to WCAG. As such, this rule doesn't test if the attribute is needed to conform to WCAG.
Accessibility support
This rule has the following accessibility support concerns:
-
Since most assistive technologies will consistently use
langoverxml:langwhen both are used, violation of this rule may not necessarily cause accessibility issues. -
<html>elements within<iframe>and<object>elements are not applicable as<iframe>and<object>elements create nested browsing contexts. However, as these elements are meant to provide a layer of isolation, the declared language of their parent browsing context will likely not be inherited, making it possible for non-validlangattributes in nested browsing contexts to also cause accessibility issues. -
Having matching primary language subtags of the
langandxml:langattribute, but non-matching language tags overall, will not cause accessibility issues unless there's a sufficiently large difference between the two language tags. One notable case is the language tags for Cantonese (zh-que) 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 in practice.
Examples
Passed
This <html> element has matching lang and xml:lang attributes:
<html lang="en" xml:lang="en"></html>
This <html> element has both a lang and xml:lang attribute with matching primary language subtags. This rule does not check the extended language subtags, nor the validity of the values.
<html lang="en-GB" xml:lang="en-XYZ"></html>
Failed
This <html> element has non-matching primary language subtags for the lang and xml:lang attributes:
<html lang="en" xml:lang="fr"></html>
Inapplicable
This <html> element has a lang attribute that is only ASCII whitespace, hence has no valid primary language subtag. The rule does therefore not apply:
<html lang=" " xml:lang="en"></html>
This rule only checks <html> elements, hence this element is not applicable:
<svg xmlns="http://www.w3.org/2000/svg" lang="en" xml:lang="en"></svg>
Acknowledgments
This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/5b7ae0/. Copyright © 2024 W3C® (MIT, ERCIM, Keio, Beihang).