# HTML Has Lang

> The <html> element must include a valid lang attribute that reflects the page’s primary natural language.

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

The `<html>` element must include a valid `lang` attribute that reflects the page’s primary natural language.

The `lang` attribute enables browsers and assistive technology to deliver correct pronunciation, spell-checking, and font selection. When it is missing or invalid, people who rely on screen readers can find the content confusing or unintelligible, and search engines may misclassify the page. Always provide a short, valid [ISO 639 language tag](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) (`en`, `fr-CA`, and so on) on every page.

## Pass Patterns

### `<html>` element with a `lang` attribute

The page declares the primary language with a valid tag.

```html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Example</title>
    </head>
    <body>
        <p>Hello world!</p>
    </body>
</html>
```

## Fail Patterns

### `<html>` element with no `lang` attribute

The page omits the `lang` attribute, so the language cannot be determined.

```html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Missing lang</title>
    </head>
    <body>
        <p>Hello world!</p>
    </body>
</html>
```

## WCAG techniques

### Sufficient techniques

-   [H57: Using the language attribute on the HTML element](https://www.w3.org/WAI/WCAG22/Techniques/html/H57)
-   [H58: Using language attributes to identify changes in the human language](https://www.w3.org/WAI/WCAG22/Techniques/html/H58)

## ACT Rules

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

## Try It Yourself

### 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 `<html>` element has a non-empty `lang` attribute.

**Actual result:** The `<html>`’s `lang` attribute is missing or empty.

## 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 web page be programmatically determinable. Declaring `lang` on the `<html>` element meets this requirement by making the language explicit to user agents and assistive technology.

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

Misidentified language immediately affects comprehension for screen reader users and can hamper text-to-speech, translation, and search indexing. The fix is straightforward, but the impact on user experience is significant across browsers and assistive technology, so the severity is classified as Serious.

## 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-lang-valid](https://knowledge.evinced.com/web/web-validations/html-lang-valid)
-   [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)
