# Language Attribute Mismatch

> The declared language of a page, or of any element with its own lang, must match the language of its text, so screen readers pronounce it correctly.

Source: https://knowledge.evinced.com/web/web-validations/language-attribute-mismatch

An element's declared language must match the language actually used in its content. This applies both to the page as a whole (the `lang` on `<html>`) and to any part of the page that has its own `lang`.

Every piece of text on a page has a declared language. It comes from the nearest `lang` in scope: the element's own `lang`, or the closest ancestor that sets one, or finally the `lang` on `<html>`. A mismatch happens when that declared language differs from the language actually used in the text, whether for the whole page or for a section, quotation, or other part of it. A mismatch can cause assistive technology to mispronounce or misinterpret text. It also affects language tools such as spell checkers and translation engines. A correct `lang` value helps these tools present content accurately.

## Pass Patterns

### Declared language matches the content

The page declares `lang="en"` and its content is in English, so the declared and detected languages agree.

```html
<html lang="en">
    <head><title>Technology News</title></head>
    <body>
        <h1>Latest technology news</h1>
        <p>Today, several major updates were announced across the technology industry, and experts said the changes will improve accessibility for everyone.</p>
        <p>During the conference, company leaders explained that the new version includes tools designed for people with visual and hearing disabilities.</p>
        <p>The developer community welcomed the news, since many had been waiting for more inclusive features for a long time.</p>
        <p>Industry analysts believe this update will mark a turning point in how accessible digital products are designed.</p>
        <p>Finally, the company confirmed that the new features will be available to all users free of charge next quarter.</p>
    </body>
</html>
```

### A foreign-language part declares its own language

A Spanish testimonial on an English page sets `lang="es"`, so the part's declared language matches its content.

```html
<section lang="es">
    <p>Hoy se anunciaron varias actualizaciones importantes en el sector de la tecnología...</p>
    <p>Durante la conferencia, los responsables explicaron que la nueva versión incluye herramientas...</p>
</section>
```

## Fail Patterns

### Declared language does not match the content

The page declares `lang="en"`, but the content is written in Spanish, so the declared language does not match the detected language.

```html
<html lang="en">
    <head><title>Noticias de tecnología</title></head>
    <body>
        <h1>Últimas noticias de tecnología</h1>
        <p>Hoy se anunciaron importantes actualizaciones en el mundo de la tecnología, y los expertos señalaron que estos cambios mejorarán la accesibilidad para todos los usuarios.</p>
        <p>Durante la conferencia, los responsables explicaron que la nueva versión incluye herramientas pensadas para personas con discapacidad visual y auditiva.</p>
        <p>La comunidad de desarrolladores recibió la noticia con entusiasmo, ya que muchos esperaban funciones más inclusivas desde hacía bastante tiempo.</p>
        <p>Los analistas del sector consideran que esta actualización marcará un antes y un después en la forma de diseñar productos digitales accesibles.</p>
        <p>Además, la empresa prometió publicar una guía detallada con recomendaciones para cumplir las pautas internacionales de accesibilidad web.</p>
        <p>Varias organizaciones que defienden los derechos de las personas con discapacidad felicitaron públicamente esta decisión tan esperada.</p>
        <p>Por último, se confirmó que las nuevas funciones estarán disponibles de forma gratuita para todos los usuarios durante el próximo trimestre.</p>
    </body>
</html>
```

### A foreign-language part is not marked

The page is `lang="en"`. This Spanish testimonial has no `lang` of its own, so it inherits `en` from the page. Its declared language (English) does not match its Spanish content.

```html
<html lang="en">
    ...
    <section>
        <h2>Testimonial</h2>
        <p>Hoy se anunciaron varias actualizaciones importantes en el sector de la tecnología, y los expertos señalaron que estos cambios mejorarán la accesibilidad para todos.</p>
        <p>Durante la conferencia, los responsables explicaron que la nueva versión incluye herramientas para personas con discapacidad visual y auditiva.</p>
    </section>
    ...
</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 language subtag matches default language](https://www.w3.org/WAI/standards-guidelines/act/rules/ucwvc8/)

## Try It Yourself

### Inspecting the browser dev-tools

1.  Open your browser's dev tools.
2.  Inspect the `<html>` element and read its `lang` value.
3.  Compare the `lang` value with the visible content on the page.
4.  For any section, quotation, or other part written in a different language, check that it has its own `lang` value matching that language.

**Expected results:** The page's `lang` value matches the predominant language of its content, and every part in a different language declares its own matching `lang`.

**Actual results:** The page, or a part of it, is in a different language than its declared `lang`, so assistive technology may render it incorrectly.

## FAQ

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

SC 3.1.1 requires the page's default language to be programmatically determinable. A `lang` value that does not match the content gives assistive technology the wrong language, so the page does not correctly satisfy the criterion.

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

SC 3.1.2 requires the language of any passage or phrase that differs from the page's default to be programmatically set. When a part of the page carries (or inherits) a `lang` that does not match its actual language, that requirement is not met, and assistive technology applies the wrong pronunciation to that part.

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

When the declared language does not match the content, screen readers load the wrong pronunciation rules and may read text in a way that is hard to understand. This affects comprehension for assistive technology users across the page, so it is rated 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. |
| 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.1 Language of Page](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |
| EN 301 549 | [9.3.1.2 Language of Parts](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |
| 508 Trusted Tester | [3.1.1-page-language-defined, 11.A](https://section508coordinators.github.io/TrustedTester/language.html#check-311-page-language-defined) | The default human language of each web page can be programmatically determined. |
| 508 Trusted Tester | [3.1.2-part-language-defined, 11.B](https://section508coordinators.github.io/TrustedTester/language.html#check-312-part-language-defined) | The human language for any content segment that differs from the default human language of the page can be programmatically determined. |

## 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)
-   [Cognitive](https://knowledge.evinced.com/a11y-essentials/personas#cognitive)

## Related Issues

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