# Valid Lang

> The lang attribute must use a valid ISO 639 language code, such as en or fr, so screen readers pick the right voice and pronounce the text correctly.

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

The `lang` attribute’s value must be a valid ISO 639 language tag.

Sometimes pages contain content in more than one language. A `lang` attribute on a specific element tells browsers and assistive technology which language engine to load for it, so text is pronounced and parsed correctly. An invalid tag such as `lang="english"` falls outside the [ISO 639 list](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) and cannot be interpreted reliably. When language metadata is wrong or missing, assistive technology may misread the content of the element, confusing people who rely on speech output.

## Pass Patterns

### A page in English with a specific part that is written in Spanish

The document’s root element uses the two-letter tag `en`, and the Spanish phrase is correctly marked with `lang="es"`. Both tags appear in ISO 639-1.

```html
<!DOCTYPE html>
<html lang="en">
    <head>…</head>
    <body>
        <p>Welcome!</p>
        <p lang="es">¡Hola!</p>
    </body>
</html>
```

### Specifying a dialect

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

```html
<!DOCTYPE html>
<html lang="en">
    <head>…</head>
    <body>
        <p>Hello world!</p>
        <p lang="fr-CA">Bonjour tout le monde!</p>
    </body>
</html>
```

## Fail Patterns

### Invalid dialect subtag separator

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

```html
<!DOCTYPE html>
<html lang="fr">
    <head>…</head>
    <body>
        <p>Bonjour tout le monde!</p>
        <p lang="en_GB">Hello world!</p>
    </body>
</html>
```

### 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
<!DOCTYPE html>
<html lang="es">
    <head>…</head>
    <body>
        <p>¡Hola!</p>
        <p lang="english">Welcome!</p>
    </body>
</html>
```

## ACT Rules

-   [Element with lang attribute has valid language tag](https://www.w3.org/WAI/standards-guidelines/act/rules/de46e4/)

## 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 element with the specific `lang` attribute (not the `html` tag which defines the language of the entire page).

**Expected result:** The primary language subtag of the element’s `lang` value (for example, `fr` in `fr-CA`) is included in the ISO 639 list.

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

## FAQ

**How does this issue relate to 3.1.2 Language of Parts?**

SC 3.1.2 requires that each passage written in a different language be programmatically identified. Invalid or absent `lang` values break that linkage, so assistive technology cannot shift to the right pronunciation library.

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

Mislabeling language stops speech engines from switching voices, which can render entire passages unintelligible for screen-reader users and anyone who depends on text-to-speech. Because it blocks comprehension rather than merely slowing it, the impact is considered serious across major browsers and assistive technologies.

## Standards and Regulations

| Standard | Success Criterion | Reference |
| --- | --- | --- |
| WCAG 2.2 | [3.1.2 Language of Parts](https://www.w3.org/TR/WCAG22/#language-of-parts) (AA) | The human language of each passage or phrase in the content can be programmatically determined, except for proper names, technical terms, words of indeterminate language, and words that have become part of the vernacular of the immediately surrounding text. |
| EN 301 549 | [9.3.1.2 Language of Parts](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)
-   [html-has-lang](https://knowledge.evinced.com/web/web-validations/html-has-lang)
-   [language-attribute-mismatch](https://knowledge.evinced.com/web/web-validations/language-attribute-mismatch)
