Last updated:

Created by:

Success Criterion:

Description

This rule checks the lang or xml:lang attribute has a valid language subtag.

Accessibility Requirements

This conformance rule relates to:

Test Procedure

Applicability

The root element of the page, if it is an html element with a non-empty lang and/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

Accessibility Support

There are known combinations of a popular operating system with browsers and assistive technologies that do not support the lang and xml:lang attributes.

While HTML5 specification indicates that xml:lang attribute takes priority over lang attribute, certain assistive technologies prioritise lang over xml:lang instead.

Background

Test Cases

Passed

Passed example 1

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

Code Snippet:
 <html lang="fr">
 
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 xml:lang="fr">
 
Example Output: Open in a new tab/ window

Passed example 3

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

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

Passed example 4

The lang attribute specified has a non-empty value & a valid primary language subtag. The rule checks for the presence of either lang or xml:lang. Empty value specified for the other attribute is ignored.

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

Passed example 5

The xml:lang attribute specified has a non-empty value & a valid primary language subtag. The rule checks for the presence of either lang or xml:lang. Empty value specified for the other attribute is ignored.

Code Snippet:
 <html lang="" xml:lang="nl">
 
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 lang="xyz">
 
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 xml:lang="xyz">
 
Example Output: Open in a new tab/ window

Failed example 3

Both the lang and xml:lang value specified are not valid values for primary language subtag.

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

Fail example 4

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

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

Inapplicable

Inapplicable example 1

The rule applies to html element and hence usage of lang attribute in svg element is not applicable.

Code Snippet:
 <svg xmlns="http://www.w3.org/2000/svg" lang="fr">
 
Example Output: Open in a new tab/ window

Inapplicable example 2

The rule applies to html element and hence usage of xml:lang attribute in svg element is not applicable.

Code Snippet:
 <svg xmlns="http://www.w3.org/2000/svg" xml:lang="fr">
 
Example Output: Open in a new tab/ window

Inapplicable example 3

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

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

Inapplicable example 4

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

Code Snippet:
 <html xml:lang="">
 
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!