# HTML Lang Valid

> The <html> element must include a valid lang attribute that accurately declares the primary language of the page.

Source: https://knowledge.evinced.com/web/web-validations/html-lang-valid

The `<html>` element must include a valid `lang` attribute that accurately declares the primary language of the page.

The `lang` attribute helps assistive technology, search engines, and browsers present content with correct pronunciation, spell-checking, and glyph selection. When the attribute is missing or invalid, people who rely on text-to-speech or translation tools may hear mispronunciations or receive incorrect results, and search engines can mis-index the page.

## Pass Patterns

### A complete page with a valid primary language

The document’s root element uses the two-letter tag `en` that is part of the [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) list. The `lang="en"` follows the [BCP 47 format](https://en.wikipedia.org/wiki/IETF_language_tag) and matches the page language, so assistive technology can announce content correctly.

```html
<!DOCTYPE html>
<html lang="en">
    ...
</html>
```

### Specifying a dialect

`fr-CA` identifies Canadian French, a valid subtag combination that helps screen readers switch voices automatically.

```html
<!DOCTYPE html>
<html lang="fr-CA">
    ...
</html>
```

## Fail Patterns

### Invalid language value due to a nonexistent language tag

`english` is not an ISO 639 code, so the user agent cannot map it to a language engine.

```html
<html lang="english">
    …
</html>
```

### Invalid dialect subtag separator

The separator between the language tag and its dialect subtag must be a hyphen (`-`), not an underscore.

```html
<html lang="en_GB">
    …
</html>
```

## ACT Rules

-   [HTML page lang attribute has valid language tag](https://www.w3.org/WAI/standards-guidelines/act/rules/bf051a/)

## Try It Yourself

Screen readers read and pronounce text in different languages based **not only** on the `lang` attribute, but also on the installed language packages and the operating system’s default language. To ensure consistent test results across all users, the tests will focus on validating allowed `lang` values from [**Set 1** of the ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) standard.

### Inspecting the browser dev-tools

1.  Open the page in a browser.
2.  Open Developer Tools and switch to the Elements panel.
3.  Select the root `<html>` element.

**Expected result:** The primary language subtag of the `lang` value (for example, `fr` in `fr-CA`) is included in the [ISO 639 list](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).

**Actual result:** The value of the `lang` attribute **is not** included in the ISO 639 list.

## FAQ

**How does this issue relate to 3.1.1 Language of Page?**

SC 3.1.1 requires that the default human language of each page be programmatically determinable. A valid `lang` attribute satisfies this requirement.

**Why is this issue marked as Serious?**

Incorrect or missing language metadata disrupts pronunciation, translation, and spell-checking, creating significant comprehension barriers for people who use assistive technology or who depend on machine translation. Because the problem affects every user on the page and impedes understanding, it warrants a Serious severity.

## Standards and Regulations

| Standard | Success Criterion | Reference |
| --- | --- | --- |
| WCAG 2.2 | [3.1.1 Language of Page](https://www.w3.org/TR/WCAG22/#language-of-page) (A) | The default human language of each web page can be programmatically determined. |
| EN 301 549 | [9.3.1.1 Language of Page](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |

## Personas impacted by this issue

-   [Screen Reader](https://knowledge.evinced.com/a11y-essentials/personas#screen-reader)
-   [Braille](https://knowledge.evinced.com/a11y-essentials/personas#braille)
-   [Voice Input](https://knowledge.evinced.com/a11y-essentials/personas#voice-input)

## Related Issues

-   [html-has-lang](https://knowledge.evinced.com/web/web-validations/html-has-lang)
-   [html-xml-lang-mismatch](https://knowledge.evinced.com/web/web-validations/html-xml-lang-mismatch)
-   [valid-lang](https://knowledge.evinced.com/web/web-validations/valid-lang)
-   [language-attribute-mismatch](https://knowledge.evinced.com/web/web-validations/language-attribute-mismatch)
