language-attribute-mismatch
Web validation
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 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.
<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 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 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
- H58: Using language attributes to identify changes in the human language
ACT Rules
Try It Yourself
Inspecting the browser dev-tools
- Open your browser's dev tools.
- Inspect the
<html>element and read itslangvalue. - Compare the
langvalue with the visible content on the page. - For any section, quotation, or other part written in a different language, check that it has its own
langvalue 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 (A) | The default human language of each web page can be programmatically determined. |
| WCAG 2.2 | 3.1.2 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 | Same as the WCAG text. |
| EN 301 549 | 9.3.1.2 Language of Parts | Same as the WCAG text. |
| 508 Trusted Tester | 3.1.1-page-language-defined, 11.A | The default human language of each web page can be programmatically determined. |
| 508 Trusted Tester | 3.1.2-part-language-defined, 11.B | The human language for any content segment that differs from the default human language of the page can be programmatically determined. |