Skip to content
Open
17 changes: 16 additions & 1 deletion _rules/html-page-lang-b5c3f8.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ input_aspects:
- DOM Tree
acknowledgments:
authors:
- Giacomo Petri
- Jey Nandakumar
previous_authors:
- Annika Nietzio
Expand All @@ -32,7 +33,11 @@ acknowledgments:
This rule applies to any [document element](https://dom.spec.whatwg.org/#document-element) if it is an `html` element for which all the following are true:

- is in a [top-level browsing context](https://html.spec.whatwg.org/#top-level-browsing-context); and
- has a [node document](https://dom.spec.whatwg.org/#concept-node-document) with a [content type](https://dom.spec.whatwg.org/#concept-document-content-type) of `text/html`.
- has a [node document](https://dom.spec.whatwg.org/#concept-node-document) with a [content type](https://dom.spec.whatwg.org/#concept-document-content-type) of `text/html`; and
- has at least one of the following [descendant](https://dom.spec.whatwg.org/#concept-tree-descendant) that is not empty or only [whitespace][]:
- [text node][] that is included in the accessibility tree; or
- an element's [accessible name][] or [accessible description](https://www.w3.org/TR/accname-1.1/#dfn-accessible-description) that is exposed in the accessibility tree; or
- the document's title.

**Note:** `html` elements within `iframe` and `object` elements are not applicable as `iframe` and `object` elements create [nested browsing contexts](https://html.spec.whatwg.org/#nested-browsing-context). However, as these elements are meant to provide a layer of isolation, the declared language of their [parent browsing context](https://html.spec.whatwg.org/#parent-browsing-context) will likely not be inherited, making it possible for empty `lang` attributes in [nested browsing contexts](https://html.spec.whatwg.org/#nested-browsing-context) to also cause accessibility issues.

Expand Down Expand Up @@ -152,4 +157,14 @@ This rule does not apply to a `math` element.
</math>
```

#### Inapplicable Example 3

This rule does not apply to content that is empty or contains only [whitespace][].

```html
<html>
<body></body>
</html>
```

[attribute value]: #attribute-value
17 changes: 16 additions & 1 deletion _rules/html-page-lang-matches-default-ucwvc8.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ input_aspects:
- Language
acknowledgments:
authors:
- Giacomo Petri
- Wilco Fiers
funding:
- WAI-Tools
Expand All @@ -39,7 +40,11 @@ This rule applies to any [document element][] if it is an `html` element for whi
- The [document element][] has a `lang` attribute with a value that has a [known primary language tag][]; and
- The [document element][] is in a [top-level browsing context][]; and
- The [document element][] has a [content type][] of `text/html`; and
- The [document element][] has a defined [default page language][].
- The [document element][] has a defined [default page language][]; and
- The [document element][] has at least one of the following [descendant](https://dom.spec.whatwg.org/#concept-tree-descendant) that is not empty or only [whitespace][]:
- [text node][] that is included in the accessibility tree; or
- an element's [accessible name][] or [accessible description](https://www.w3.org/TR/accname-1.1/#dfn-accessible-description) that is exposed in the accessibility tree; or
- the document's title.

## Expectation

Expand Down Expand Up @@ -322,6 +327,16 @@ The `lang` [attribute value][] of this page is a [grandfathered tag][grandfather
</html>
```

#### Inapplicable Example 7

This rule does not apply to content that is empty or contains only [whitespace][].

```html
<html lang="em-US">
<body></body>
</html>
```

[attribute value]: #attribute-value
[content type]: https://dom.spec.whatwg.org/#concept-document-content-type 'DOM content type, as of 2020/06/05'
[default page language]: #default-page-language
Expand Down
56 changes: 50 additions & 6 deletions _rules/html-page-lang-valid-bf051a.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ input_aspects:
- DOM Tree
acknowledgments:
authors:
- Giacomo Petri
- Jey Nandakumar
previous_authors:
- Annika Nietzio
Expand All @@ -33,7 +34,11 @@ This rule applies to any [document element](https://dom.spec.whatwg.org/#documen

- has a `lang` attribute that is neither empty ("") nor only [ASCII whitespace](https://infra.spec.whatwg.org/#ascii-whitespace); and
- is in a [top-level browsing context](https://html.spec.whatwg.org/#top-level-browsing-context); and
- has a [node document](https://dom.spec.whatwg.org/#concept-node-document) with a [content type](https://dom.spec.whatwg.org/#concept-document-content-type) of `text/html`.
- has a [node document](https://dom.spec.whatwg.org/#concept-node-document) with a [content type](https://dom.spec.whatwg.org/#concept-document-content-type) of `text/html`; and
- has at least one of the following [descendant](https://dom.spec.whatwg.org/#concept-tree-descendant) that is not empty or only [whitespace][]:
- [text node][] that is included in the accessibility tree; or
- an element's [accessible name][] or [accessible description](https://www.w3.org/TR/accname-1.1/#dfn-accessible-description) that is exposed in the accessibility tree; or
- the document's title.

## Expectation

Expand Down Expand Up @@ -73,18 +78,39 @@ This rule is only applicable to non-embedded HTML pages. HTML pages embedded int

#### Passed Example 1

This `html` element has a `lang` attribute with a [known primary language tag][].
This `html` element has a `lang` attribute with a [known primary language tag][] and non-empty `body` content.

```html
<html lang="FR"></html>
<html lang="it">
<body>
<p>Amo le regole ACT!</p>
</body>
</html>
```

#### Passed Example 2

This `html` element has a `lang` attribute with a [known primary language tag][] and non-empty `title`.

```html
<html lang="it">
<head>
<title>Amo le regole ACT!</title>
</head>
<body></body>
</html>
```

#### Passed Example 3

This `html` element has a `lang` attribute with a [known primary language tag][] even though the [region subtag][] is not.

```html
<html lang="en-US-GB"></html>
<html lang="en-US-GB">
<body>
<p lang="en">I love ACT rules!</p>
</body>
</html>
```

### Failed
Expand All @@ -94,15 +120,23 @@ This `html` element has a `lang` attribute with a [known primary language tag][]
This `html` element has a `lang` attribute, with no [known primary language tag][].

```html
<html lang="em-US"></html>
<html lang="em-US">
<body>
<p lang="en">I love ACT rules!</p>
</body>
</html>
```

#### Failed Example 2

This `html` element has a `lang` attribute, with no [known primary language tag][].

```html
<html lang="#1"></html>
<html lang="#1">
<body>
<p lang="en">I love ACT rules!</p>
</body>
</html>
```

#### Failed Example 3
Expand Down Expand Up @@ -139,6 +173,16 @@ This rule does not apply to `svg` elements.
<svg xmlns="http://www.w3.org/2000/svg" lang="fr"></svg>
```

#### Inapplicable Example 2

This rule does not apply to content that is empty or contains only [whitespace][].

```html
<html lang="em-US">
<body></body>
</html>
```

[grandfathered tags]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.8
[iso 639.2]: https://www.loc.gov/standards/iso639-2/php/code_list.php 'ISO 639.2: Codes for the Representation of Names of Languages'
[region subtag]: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.4 'Definition of region subtag'
Expand Down