HTML page language subtag matches default language

Applicability

This rule applies to any document element if it is an html element for which all of the following are true:

Expectation

For each test target, the [primary language][] of the [valid language tag][] matches the default page language of the test target.

Assumptions

Accessibility Support

There are no major accessibility support issues known for this rule.

Background

Test Cases

Passed

Passed Example 1

This page has a lang attribute value of en (English), which matches the default language of the page. The default language is English because all words are English.

<html lang="en">
	<head>
		<title>ACT Rules Format 1.0 - Abstract</title>
	</head>
	<body>
		<p>
			The Accessibility Conformance Testing (ACT) Rules Format 1.0 defines a format for writing accessibility test
			rules. These test rules can be used for developing automated testing tools and manual testing methodologies. It
			provides a common format that allows any party involved in accessibility testing to document and share their
			testing procedures in a robust and understandable manner. This enables transparency and harmonization of testing
			methods, including methods implemented by accessibility test tools.
		</p>
	</body>
</html>

Passed Example 2

This page has a lang attribute value of en (English), which matches the default language of the page. The default language is English because all but a few words are English.

<html lang="en">
	<head>
		<title>Gelukkig</title>
	</head>
	<body>
		<p>The Dutch word "gelukkig" has no equivalent in English.</p>
	</body>
</html>

Passed Example 3

This page has lang attribute value of nl (Dutch), which matches the default language of the page. The default language is Dutch because all English words are in a p element with a lang attribute value of en.

<html lang="nl">
	<head>
		<title>Met de kippen op stok</title>
	</head>
	<body>
		<blockquote>
			<p>"Hij ging met de kippen op stok"</p>
		</blockquote>
		<p lang="en">
			This Dutch phrase literally translates into "He went to roost with the chickens", but it means that he went to bed
			early.
		</p>
	</body>
</html>

Passed Example 4

This page has a lang attribute value of en (English), which matches the default language of the page. The default language is English because the accessible texts are English, and all other text is in a p element with a lang attribute value of nl.

<html lang="en">
	<head>
		<title>Fireworks over Paris</title>
	</head>
	<body>
		<img src="/test-assets/shared/fireworks.jpg" alt="Fireworks over Paris" />
		<p lang="nl">
			Gelukkig nieuwjaar!
		</p>
	</body>
</html>

Failed

Failed Example 1

This page has a lang attribute value of da (Danish), which does not match the default language of the page. The default language is English because all words are English.

<html lang="da">
	<head>
		<title>ACT Rules Format 1.0 - Abstract</title>
	</head>
	<body>
		<p>
			The Accessibility Conformance Testing (ACT) Rules Format 1.0 defines a format for writing accessibility test
			rules. These test rules can be used for developing automated testing tools and manual testing methodologies. It
			provides a common format that allows any party involved in accessibility testing to document and share their
			testing procedures in a robust and understandable manner. This enables transparency and harmonization of testing
			methods, including methods implemented by accessibility test tools.
		</p>
	</body>
</html>

Failed Example 2

This page has a lang attribute value of nl (Dutch), which does not match the default language of the page. The default language is English because all but a few words are English.

<html lang="nl">
	<head>
		<title>Gelukkig</title>
	</head>
	<body>
		<p>The Dutch word "gelukkig" has no equivalent in English.</p>
	</body>
</html>

Failed Example 3

This page has a lang attribute value of en (English), which does not match the default language of the page. The default language is Dutch because all English words are in a p element with a lang attribute value of en.

<html lang="en">
	<head>
		<title>Met de kippen op stok</title>
	</head>
	<body>
		<blockquote>
			<p>"Hij ging met de kippen op stok"</p>
		</blockquote>
		<p lang="en">
			This Dutch phrase literally translates into "He went to roost with the chickens", but it means that he went to bed
			early.
		</p>
	</body>
</html>

Failed Example 4

This page has a lang attribute value of nl (Dutch), which does not match the default language of the page. The default language is English because the accessible texts are English, and all other text is in a p element with a lang attribute value of nl.

<html lang="nl">
	<head>
		<title>Fireworks over Paris</title>
	</head>
	<body>
		<img src="/test-assets/shared/fireworks.jpg" alt="Fireworks over Paris" />
		<p lang="nl">
			Gelukkig nieuwjaar!
		</p>
	</body>
</html>

Failed Example 5

This page has a lang attribute value of nl (Dutch), which does not match the default language of the page. The default language is English because the accessible name of the img element is English. The lang attribute on the p element is effectively ignored.

<html lang="nl">
	<head>
		<title>Paris</title>
	</head>
	<body>
		<img src="/test-assets/shared/fireworks.jpg" aria-labelledby="caption" />
		<p lang="en" id="caption" hidden>
			Fireworks over Paris!
		</p>
	</body>
</html>

Inapplicable

Inapplicable Example 1

This is an SVG document, not an HTML document.

<svg xmlns="http://www.w3.org/2000/svg" lang="fr"></svg>

Inapplicable Example 2

This page has an undefined default language because it has no content or document title.

<html></html>

Inapplicable Example 3

This page has an undefined default language because it has no document title and all its content is wrapped in an element with a lang attribute.

<html>
	<p lang="en">
		The Accessibility Conformance Testing (ACT) Rules Format 1.0 defines a format for writing accessibility test rules.
		These test rules can be used for developing automated testing tools and manual testing methodologies. It provides a
		common format that allows any party involved in accessibility testing to document and share their testing procedures
		in a robust and understandable manner. This enables transparency and harmonization of testing methods, including
		methods implemented by accessibility test tools.
	</p>
</html>

Inapplicable Example 4

This page has an undefined default language because it can either be English or French.

<html lang="fr">
	<head>
		<title>Paul put dire comment on tape</title>
	</head>
	<body>
		<p>Paul put dire comment on tape</p>
	</body>
</html>

Inapplicable Example 5

The lang attribute value of this page is an [iso 639.2][] three letters code, hence not a [valid language tag][].

<html lang="eng">
	<body>
		<p lang="en">I love ACT rules!</p>
	</body>
</html>

Inapplicable Example 6

The lang attribute value of this page is a grandfathered tag, hence not a [valid language tag][].

<html lang="i-lux">
	<body>
		<p lang="lb">Lëtzebuerg ass e Land an Europa.</p>
	</body>
</html>

Glossary

Accessible Name

The accessible name is the programmatically determined name of a user interface element that is included in the accessibility tree.

The accessible name is calculated using the accessible name and description computation.

For native markup languages, such as HTML and SVG, additional information on how to calculate the accessible name can be found in HTML Accessibility API Mappings 1.0, Accessible Name and Description Computation (working draft) and SVG Accessibility API Mappings, Name and Description (working draft).

For more details, see examples of accessible name.

Note: As per the accessible name and description computation, each element always has an accessible name. When no accessible name is provided, the element will nonetheless be assigned an empty ("") one.

Note: As per the accessible name and description computation, accessible names are flat string trimmed of leading and trailing whitespace. Notably, it is not possible for a non-empty accessible name to be composed only of whitespace since these must be trimmed.

Attribute value

The attribute value of a content attribute set on an HTML element is the value that the attribute gets after being parsed and computed according to specifications. It may differ from the value that is actually written in the HTML code due to trimming whitespace or non-digits characters, default values, or case-insensitivity.

Some notable case of attribute value, among others:

This list is not exhaustive, and only serves as an illustration for some of the most common cases.

The attribute value of an IDL attribute is the value returned on getting it. Note that when an IDL attribute [reflects][reflect] a content attribute, they have the same attribute value.

Default Page Language

The default language of a [web page][] is the [most common language][] of its top-level browsing context document, if it is unique. If this document has either no or several [most common languages][most common language], then it has no default language.

For more details, see examples of default language.

Focusable

Elements that can become the target of keyboard input as described in the HTML specification of focusable and can be focused.

Included in the accessibility tree

Elements included in the accessibility tree of platform specific accessibility APIs are exposed to assistive technologies. This allows users of assistive technology to access the elements in a way that meets the requirements of the individual user.

The general rules for when elements are included in the accessibility tree are defined in the core accessibility API mappings. For native markup languages, such as HTML and SVG, additional rules for when elements are included in the accessibility tree can be found in the HTML accessibility API mappings (working draft) and the SVG accessibility API mappings (working draft).

For more details, see examples of included in the accessibility tree.

Programmatically hidden elements are removed from the accessibility tree. However, some browsers will leave focusable elements with an aria-hidden attribute set to true in the accessibility tree. Because they are hidden, these elements are considered not included in the accessibility tree. This may cause confusion for users of assistive technologies because they may still be able to interact with these focusable elements using sequential keyboard navigation, even though the element should not be included in the accessibility tree.

Most Common Language of an Element

The most common language of an element is determined by counting the number of words in the [text inheriting its programmatic language][] from this element that are part of any of the languages in the [language subtag registry][]. The same word can be part of multiple languages. In case of ties, the element has several most common languages. If there are no words in the [text inheriting its programmatic language][] from the element, then it has no most common language.

For more details, see examples of most common language.

Outcome

An outcome is a conclusion that comes from evaluating an ACT Rule on a test subject or one of its constituent test target. An outcome can be one of the three following types:

Note: A rule has one passed or failed outcome for every test target. When there are no test targets the rule has one inapplicable outcome. This means that each test subject will have one or more outcomes.

Note: Implementations using the EARL10-Schema can express the outcome with the outcome property. In addition to passed, failed and inapplicable, EARL 1.0 also defined an incomplete outcome. While this cannot be the outcome of an ACT Rule when applied in its entirety, it often happens that rules are only partially evaluated. For example, when applicability was automated, but the expectations have to be evaluated manually. Such “interim” results can be expressed with the incomplete outcome.

Programmatically Hidden

An HTML element is programmatically hidden if either it has a computed CSS property visibility whose value is not visible; or at least one of the following is true for any of its inclusive ancestors in the flat tree:

Note: Contrarily to the other conditions, the visibility CSS property may be reverted by descendants.

Text Inheriting its Programmatic Language from an Element

The text inheriting its programmatic language from an element E is composed of all the following texts:

An element F is an element inheriting its programmatic language from an element E if at least one of the following conditions is true (recursively):

Valid Language Tag

A [language tag][] is valid if its [primary language subtag][] exists in the [language subtag registry][] with a [Type field][] whose field-body value is language.

A “language tag” is here to be understood as in the first paragraph of the [RFC 5646 language tag syntax][language tag], i.e. a sequence of subtags separated by hyphens, where a subtag is any sequence of alphanumerical characters. Thus, this definition intentionally differs from the strict [RFC 5646 syntax][language tag] (and ABNF grammar) as user agents and assistive technologies are more lenient in what they accept. The definition is however consistent with the behavior of the :lang() pseudo-selector as defined by [Selectors Level 3][]. For example, de-hello would be an accepted way to indicate German in current user agents and assistive technologies, despite not being valid according to [RFC 5646 grammar][language tag]. As a consequence of this definition, however, grandfathered tags are not correctly recognized as valid language subtags.

Subtags, notably the [primary language subtag][], are case insensitive. Hence comparison with the [language subtag registry][] must be done in a case insensitive way.

Visible

Content perceivable through sight.

Content is considered visible if making it fully transparent would result in a difference in the pixels rendered for any part of the document that is currently within the viewport or can be brought into the viewport via scrolling.

Content is defined in WCAG.

For more details, see examples of visible.

Web page (HTML)

An HTML web page is the set of all fully active documents which share the same top-level browsing context.

Note: Nesting of browsing context mostly happens with iframe and object. Thus a web page will most of the time be a “top-level” document and all its iframe and object (recursively).

Note: Web pages as defined by WCAG are not restricted to the HTML technology but can also include, e.g., PDF or DOCX documents.

Note: Although web pages as defined here are sets of documents (and do not contain other kind of nodes), one can abusively write that any node is “in a web page” if it is a shadow-including descendant of a document that is part of that web page.

Implementations

There are currently no known implementations for this rule. If you would like to contribute an implementation, please read the ACT Implementations page for details.

Changelog

This is the first version of this ACT rule.

[iso 639.2]: https://www.loc.gov/standards/iso639-2/php/code_list.php ‘ISO 639.2 [language subtag registry]: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry ‘Language Subtag Registry’ [language tag]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1 [most common language]: #most-common-element-language ‘Definition of Most Common Language of an Element’ [numbers]: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#numbers ‘HTML Specification of Number Parsing’ [primary language subtag]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.1 [primary language]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.1 ‘Definition of primary language subtag’ [reflect]: https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes ‘HTML specification of Reflecting Content Attributes in IDL Attributes’ [rfc 5646]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1 [sc311]: https://www.w3.org/TR/WCAG21/#language-of-page ‘Success Criterion 3.1.1 Language of Page’ [selectors level 3]: https://drafts.csswg.org/selectors-3/#lang-pseudo [space separated]: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#space-separated-tokens ‘HTML Specification of Space Separated Tokens’ [text inheriting its programmatic language]: #text-inheriting-language ‘Definition of Text Inheriting its Programmatic Language from an Element’ [text nodes]: https://dom.spec.whatwg.org/#text ‘DOM text, as of 2020/06/05’ [top-level browsing context]: https://html.spec.whatwg.org/#top-level-browsing-context ‘HTML top-level browsing context, as of 2020/06/05’ [type field]: https://www.rfc-editor.org/rfc/rfc5646.html#section-3.1.3 [valid language tag]: #valid-language-tag [visible]: #visible ‘Definition of Visible’ [wai-aria specification]: https://www.w3.org/TR/wai-aria-1.1/#propcharacteristic_value ‘WAI-ARIA Specification of States and Properties Value’ [web page]: #web-page-html ‘Definition of Web Page (HTML)’

Back to Top