Last updated:

Created by:

Success Criterion:

Description

This rule checks that the html element has a non-empty lang or xml:lang attribute.

Accessibility Requirements

This conformance rule relates to:

Test Procedure

Applicability

The root element of the page, if it is an html element.

Expectation

The test target has a non-empty lang or xml:lang attribute.

Note: HTML5 recommends using lang instead of xml:lang. This is not known to impact accessibility, which is why use of both is permitted by this rule.

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.

Background

Test Cases

Passed

Passed example 1

The lang attribute specified has a non-empty value.

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

Passed example 2

The xml:lang attribute specified has a non-empty value.

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

Passed example 3

The lang and xml:lang attribute specified has a non-empty value.

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

Passed example 4

The lang attribute specified has a non-empty value. The rule expects a non-empty value on either the lang or xml:lang attributes.

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

Passed example 5

The xml:lang attribute specified has a non-empty value. The rule expects a non-empty value on either the lang or xml:lang attributes.

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

Passed example 6

The lang attribute specified has a non-empty value. The rule does not verify the validity of the value specified and checks only for presence of a value.

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

Passed example 7

The xml:lang attribute specified has a non-empty value. The rule does not verify the validity of the value specified and checks only for presence of a value.

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

Failed

Failed example 1

There were no lang or xml:lang attribute specified.

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

Failed example 2

The xml:lang attribute specified has an empty value.

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

Failed example 3

The lang attribute specified has an empty value.

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

Failed example 4

The lang and xml:lang attribute specified has an empty value.

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

Inapplicable

Inapplicable example 1

The rule does not apply to svg element.

Code Snippet:
 <svg xmlns="http://www.w3.org/2000/svg" lang="en"></svg>
 
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/

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!