SIA-R7lang attributes within the <body> element have a valid value
Accessibility requirements
This rule tests conformance of the following accessibility requirements:
Description
This rule checks that lang attributes specified on elements within the <body> element have a valid value.
Applicability
This rule applies to every element in the HTML namespace that:
- is an inclusive descendant in the flat tree of a
<body>element; and - has a
langattribute that is neither empty nor only ASCII whitespace; and - there is some non-whitespace only text inheriting its programmatic language from this element.
Expectations
- The value of the attribute is a valid language tag.
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 no known accessibility support concerns.
Examples
Passed
These lang attributes are valid language tags and therefore pass the rule:
<article lang="en"></article>
<blockquote lang="fr-CH"></blockquote>
Failed
These lang attributes are not valid language tags and therefore fail the rule:
<p lang="english"></p>
<article lang="xyz"></article>
Inapplicable
This document has an element that has a lang attribute with a value that is a valid language tag, but the element is not within the <body> element and is therefore inapplicable:
<html lang="en">
<body></body>
</html>
This element that has a lang attribute with a value that is empty and is therefore inapplicable:
<article lang=""></article>
This element that has a lang attribute with a value that is only ASCII whitespace and is therefore inapplicable:
<article lang=" "></article>
Acknowledgments
This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/de46e4/. Copyright © 2025 W3C® (MIT, ERCIM, Keio, Beihang).