text: there is some text inheriting its programmatic language from the element which is neither empty nor only whitespace.
Expectation
For each test target, the langattribute value has a known primary language tag.
Background
Assumptions
This rule assumes that the langattribute value is used to indicate the language of a section of the content. If the langattribute value is used for something else (for example to indicate the programming language of a code element), the content may still conform to WCAG despite failing this rule.
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.
This rule assumes that the text nodes contain text that express something in human language and therefore need a correct programmatic language.
Accessibility Support
There are differences in how assistive technologies handle unknown and invalid language tags. Some will default to the language of the page, whereas others will default to the closest ancestor with a valid lang attribute.
This article element has a langattribute value which has a known primary language tag.
<htmllang="es"><body><articlelang="en">
They wandered into a strange Tiki bar on the edge of the small beach town.
</article></body></html>
Passed Example 2
This blockquote element has a langattribute value which has a known primary language tag. The region section ("CH") in the value is ignored by the rule (and the definition of known primary language tag).
<htmllang="en"><body><blockquotelang="fr-CH">
Ils ont trouvé un étrange bar Tiki aux abords de la petite ville balnéaire.
</blockquote></body></html>
Passed Example 3
This p element has a langattribute value which has a known primary language tag, but a syntactically invalid region subtag which is ignored by the rule.
<htmllang="fr"><body><plang="en-US-GB">
They wandered into a strange Tiki bar on the edge of the small beach town.
</p></body></html>
Passed Example 4
This div element has a valid langattribute value. There is no text inheriting its programmatic language from the article element, therefore its lang attribute is not considered by the rule.
<htmllang="fr"><body><articlelang="invalid"><divlang="en">
They wandered into a strange Tiki bar on the edge of the small beach town.
</div></article></body></html>
Passed Example 5
This div element has a valid langattribute value. The accessible name of the image is text inheriting its programmatic language from the div element.
<htmllang="es"><body><divlang="EN"><imgsrc="/test-assets/shared/fireworks.jpg"alt="Fireworks over Paris" /></div></body></html>
Failed
Failed Example 1
This article element has a langattribute value which does not have a known primary language tag because its primary language subtag does not exist in the language subtag registry.
<htmllang="es"><body><articlelang="dutch">
Zij liepen een vreemde Tiki bar binnen, aan de rand van een dorpje aan het strand.
</article></body></html>
Failed Example 2
This article element has a langattribute value which has no known primary language tag.
<htmllang="en"><body><articlelang="#!">
They wandered into a strange Tiki bar on the edge of the small beach town.
</article></body></html>
Failed Example 3
This article element has a langattribute value which consists of only whitespace and thus has no known primary language tag.
<htmllang="fr"><body><articlelang=" ">
They wandered into a strange Tiki bar on the edge of the small beach town.
</article></body></html>
Failed Example 4
The langattribute value does not have a valid language tag. Even though the p element is not included in the accessibility tree due to the presence of the aria-hidden="true" attribute, it is visible; therefore its content is text inheriting its programmatic language from the article element. Hence, the lang attribute must be valid.
<htmllang="es"><body><articlelang="english"><paria-hidden="true">
They wandered into a strange Tiki bar on the edge of the small beach town.
</p></article></body></html>
Failed Example 5
The langattribute value does not have a valid language tag. Even though the p element is not visible due to it being moved off-screen, it is included in the accessibility tree; therefore its content is text inheriting its programmatic language from the article element. Hence, the lang attribute must be valid.
<htmllang="fr"><body><articlelang="English"><pstyle="position: absolute; top: -9999px">
They wandered into a strange Tiki bar on the edge of the small beach town.
</p></article></body></html>
Failed Example 6
This div element has an invalid langattribute value. There is no text inheriting its programmatic language from the article element, therefore its lang attribute is not considered by the rule.
<htmllang="es"><body><articlelang="en"><divlang="invalid">
They wandered into a strange Tiki bar on the edge of the small beach town.
</div></article></body></html>
Failed Example 7
This div element has an invalid langattribute value. The accessible name of the image is text inheriting its programmatic language from the div element.
<htmllang="en"><body><divlang="invalid"><imgsrc="/test-assets/shared/fireworks.jpg"alt="Fireworks over Paris" /></div></body></html>
Failed Example 8
The langattribute value of this p element is an iso 639.2 three letters code, which has no known primary language tag.
<htmllang="en"><body><plang="eng">I love ACT rules!</p></body></html>
Failed Example 9
The langattribute value of this p element is a grandfathered tag, which has no known primary language tag.
<htmllang="lb"><body><plang="i-lux">Lëtzebuerg ass e Land an Europa.</p></body></html>
Inapplicable
Inapplicable Example 1
There is no element with a lang attribute value which is a descendant of a body element.
<htmllang="en"><body>
They wandered into a strange Tiki bar on the edge of the small beach town.
</body></html>
Inapplicable Example 2
There is no element which is a descendant of a body element and has a non-empty langattribute value.
<htmllang="en"><body><articlelang="">
They wandered into a strange Tiki bar on the edge of the small beach town.
</article></body></html>
Inapplicable Example 3
There is no element with a text node as a descendant in the flat tree that is either visible or included in the accessibility tree.
<htmllang="en"><body><plang="hidden"><spanstyle="display: none;">
They wandered into a strange Tiki bar on the edge of the small beach town.
</span></p></body></html>
Inapplicable Example 4
There is no text inheriting its programmatic language from this div element.