Last updated:

Created by:

Success Criterion:

Description

This rule checks that lang or xml:lang attributes on elements within the body of a web page has a valid language subtag.

Accessibility Requirements

This conformance rule relates to:

Test Procedure

Applicability

Any DOM element, within the body of a webpage with a non-empty lang or xml:lang attribute.

Expectation

The lang and xml:lang attributes have a valid language subtag if the attribute is non-empty.

Assumptions

There are currently no assumptions

Background

Test Cases

Passed

Passed example 1

The lang attribute specified has a non-empty value & a valid primary language subtag.

Code Snippet:
 <html>
<body> 
  <article lang="en"></article>
</body>
</html>
 
Example Output: Open in a new tab/ window

Passed example 2

The xml:lang attribute specified has a non-empty value & a valid primary language subtag.

Code Snippet:
 <html>
<body>
  <p xml:lang="DE"></p>
</body>
</html>
 
Example Output: Open in a new tab/ window

Passed example 3

The lang attribute specified has a non-empty value & a valid primary language subtag. The region section in the value is ignored by the rule.

Code Snippet:
 <html>
<body>
  <blockquote lang="fr-CH"></blockquote>
</body>
</html>
 
Example Output: Open in a new tab/ window

Passed example 4

The lang and xml:lang attribute specified has a non-empty value & a valid primary language subtag.

Code Snippet:
 <html>
<body>
  <p lang="en" xml:lang="en-GB">Good Morning.</p>
</body>
</html>
 
Example Output: Open in a new tab/ window

Failed

Failed example 1

The lang attribute value is not a valid primary language subtag.

Code Snippet:
 <html>
<body>
  <article lang="dutch"></article>
</body>
</html>
 
Example Output: Open in a new tab/ window

Failed example 2

The xml:lang attribute value is not a valid primary language subtag.

Code Snippet:
 <html>
<body>
  <p xml:lang="english"></p>
</body>
</html>
 
Example Output: Open in a new tab/ window

Fail example 3

The lang attribute value has a valid primary language subtag, but a syntactically invalid region subtag.

Code Snippet:
 <html>
<body>
  <p lang="en-US-GB"></p>
</body>
</html>
 
Example Output: Open in a new tab/ window

Inapplicable

Inapplicable example 1

The rule applies to elements with the body of a webpage. html elements are ignored by the rule.

Code Snippet:
 <html lang="en">
	<body>
	</body>
</html>
 
Example Output: Open in a new tab/ window

Inapplicable example 2

An empty value for lang attribute is ignored by this rule, as the applicability specifies only non-empty values.

Code Snippet:
 <html>
	<body>
		<article lang=""></article>
	</body>
</html>
 
Example Output: Open in a new tab/ window

Inapplicable example 3

An empty value for xml:lang attribute is ignored by this rule, as the applicability specifies only non-empty values.

Code Snippet:
 <html>
	<body>
		<article xml:lang=""></article>
	</body>
</html>
 
Example Output: Open in a new tab/ window

Glossary

Non-empty text string

A string of characters (text) is considered “non-empty” if it contains 1 or more characters that are contained within any of the following unicode categories:

  • Ll: Letter, Lowercase
  • Lu: Letter, Uppercase
  • Lt: Letter, Titlecase
  • Lo: Letter, Other
  • Lm: Letter, Modifier
  • Nd: Number, Decimal Digit

For more details on unicode categories, check out www.fileformat.info/info/unicode/category/

Valid Language Subtag

A text string following the syntax as defined in BCP 47, with a primary language from the language subtag registry.

Background

  • https://www.ietf.org/rfc/bcp/bcp47.txt
  • http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

Test Aspects

Test aspects are defined as part of the ACT Rules format 1.0.
  • DOM Tree

Contribute






GitHub

Contributing is open to anyone. We welcome any new issues or pull requests for changes. Auto WCAG Rules has conference calls every 4 weeks. If you are interested in becoming an active contributor or reviewer, we ask that you join the Auto WCAG Rules community group through the W3C Website. This requires setting up a W3C account, may require approval by the organization you work for if they are a W3C member.

Learn more about contributing to Auto WCAG Rules Join the Auto WCAG Rules community group now!