Last updated:

Created by:

Success Criterion:

Description

The rule checks that for the html element, there is no mismatch between the primary language in non-empty lang and xml:lang attributes, if both are used.

Accessibility Requirements

This conformance rule relates to:

Test Procedure

Applicability

The root element of the page, if it is an html element with both non-empty lang and xml:lang attributes that has a valid language subtag.

Expectation

The value of the primary language subtag (characters before the first dash) for the lang and xml:lang attributes are the same.

Note: HTML 5 specification requires the lang and xml:lang attributes to match exactly. This is not known to impact accessibility, which is why it is permitted in this rule.

Assumptions

Accessibility Support

Since most assistive technologies will consistently use lang over xml:lang when both are used, violation of this rule may not necessarily be a violation of WCAG 2. Only when there are inconsistencies between assistive technologies, as to which attribute is used to determine the language, does this lead to a violation of SC 3.1.1.

Background

Test Cases

Passed

Passed example 1

html element with matching value for lang and xml:lang.

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

Passed example 2

html element with varied case but matching value for lang and xml:lang.

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

Passed example 3

html element with varied case but matching primary sub-tag value for lang and xml:lang.

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

Passed example 4

html element with varied case but matching primary sub-tag value for lang and xml:lang.

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

Passed example 5

html element with varied case but matching primary sub-tag value for lang and xml:lang, albeit the value XYZ is not valid.

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

Failed

Failed example 1

html element with non-matching value for lang and xml:lang.

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

Inapplicable

Inapplicable example 1

svg element is not applicable for this rule.

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

Inapplicable example 2

xml:lang is empty, the rule mandates non-empty values.

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

Inapplicable example 3

Only non-empty values are considered.

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