Skip to content

Latest commit

 

History

History
153 lines (98 loc) · 3.99 KB

html-lang-valid-bf051a.md

File metadata and controls

153 lines (98 loc) · 3.99 KB
id name description success_criterion test_aspects authors
bf051a
Validity of HTML Lang attribute
This rule checks the lang or xml:lang attribute has a valid language subtag.
3.1.1
DOM Tree
Annika Nietzio
Jey Nandakumar

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.

<html lang="fr"></html>

Passed example 2

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

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

Passed example 3

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

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

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.

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

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.

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

Failed

Failed example 1

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

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

Failed example 2

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

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

Failed example 3

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

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

Fail example 4

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

<html lang="en-US-GB"></html>

Inapplicable

Inapplicable example 1

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

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

Inapplicable example 2

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

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

Inapplicable example 3

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

<html lang=""></html>

Inapplicable example 4

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

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