HTML has lang attribute

  • Rule Typeatomic
  • Rule ID: b5c3f8
  • Last modified: Aug 21, 2019
  • Accessibility Requirements Mapping
    • 3.1.1 Language of Page (Level: A)
      • Learn More about 3.1.1 (Language of Page)
      • Required for conformance to WCAG 2.0 and above on level A and above
      • Outcome mapping:
        • Any failed outcomes: not satisfied
        • All passed outcomes: further testing is needed
        • An inapplicable outcome: further testing is needed
  • Input Aspects

Description

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

Applicability

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

Expectation

The test target has a lang or xml:lang attribute that is not empty ("").

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.

<html lang="en"></html>

Passed Example 2

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

<html xml:lang="en"></html>

Passed Example 3

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

<html xml:lang="en" lang="en"></html>

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.

<html xml:lang="" lang="en"></html>

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.

<html xml:lang="en" lang=""></html>

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.

<html lang="xyz"></html>

Passed Example 7

The xml:lang attribute specifies a value that is not empty (""). The rule does not verify the validity of the value specified and checks only for presence of a value.

<html xml:lang="xyz"></html>

Passed Example 8

The xml:lang attribute specifies a value that is not empty (""). The rule does not verify the validity of the value specified and checks only for presence of a value.

<html xml:lang="123"></html>

Passed Example 9

The xml:lang attribute specifies a value that is not empty (""). The rule does not verify the validity of the value specified and checks only for presence of a value.

<html xml:lang="#!"></html>

Passed Example 10

The xml:lang attribute specifies a value that is not empty (""). The rule does not verify the validity of the value specified and checks only for presence of a value.

<html xml:lang=" "></html>

Failed

Failed Example 1

There were no lang or xml:lang attribute specified.

<html></html>

Failed Example 2

The xml:lang attribute specified is empty ("").

<html xml:lang=""></html>

Failed Example 3

The lang attribute specified is empty ("").

<html lang=""></html>

Failed Example 4

The lang and xml:lang attribute specified is empty ("").

<html xml:lang="" lang=""></html>

Inapplicable

Inapplicable Example 1

The rule does not apply to svg element.

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

Glossary

Outcome

key: outcome

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:

  • Inapplicable: No part of the test subject matches the applicability
  • Passed: A test target meets all expectations
  • Failed: A test target does not meet all expectations

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: Implementers 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.


Changelog

Aug 21, 2019test: add tests to verify h4 headings (#810)
Aug 21, 2019fix: update links to WCAG21 resources (#776)
May 18, 2019chore: Validating rules frontmatter on CI (#551)
May 15, 2019Glossary and Rule update: Replacing "non-empty" definition (#430)
May 9, 2019Chore: Adapt site to ACT Rules CR format (#547)
May 7, 2019Template update - HTML has lang attribute (#509)
Apr 29, 2019chore: rename files and update associations (#489)
Apr 16, 2019chore: add unique id to all rules (#478)
Apr 15, 2019chore: WCAG ACT RULES CG Website Update (#437)
Jan 9, 2019fix: refer webpage definition (#386)
Oct 10, 2018chore: Mark all SVG documents and add missing namespaces (#300)
Oct 9, 2018Fix: testcase generation (#296)
Sep 19, 2018fix: test cases for rules
Aug 30, 2018Chore: Update test cases format and descriptions (#230)
Jul 13, 2018fix: links in background were not anchors (#187)
Jun 25, 2018FINAL: SC3-1-1-html-has-lang (#107)

Useful Links


Implementations

Tool NameCreated ByReport
AlfaSiteimproveView Report
QualWebLASIGE, Faculdade de Ciências da Universidade de LisboaView Report

Acknowledgements