---
title: "The local language attribute matches the actual language"
date: "2025-03-27T10:29:33+00:00"
summary: "Ensure correct language attributes for multilingual content to improve accessibility and user experience."
image:
type: "page"
url: "/web-governance/local-language-attribute-matches-actual-language"
id: "9a2f8dfa-f24c-4784-8f31-a8921e06168d"
---

Table of contents will be added

3.1.2 Language of Parts

Introduction
------------

This document provides information about the following Acquia Web Governance accessibility check:

*   The local language attribute matches the actual language

What
----

The `lang` attribute of the local language must correctly identify the language of the content it applies to. This ensures that assistive technologies, such as screen readers, can correctly interpret and pronounce the text.

The check verifies that:

*   The `lang` attribute is present and correctly set for sections of content in different languages.
*   The declared language matches the actual language used in the text.

Webpages with sections of text in different languages must have an associated `lang` attribute for each language. Examples include:

*   **A webpage in English with a passage in French**
    
    *   One `lang` attribute must indicate that the language for webpage is English and another `lang` attribute must indicate the section in French.
        
*   **An HTML webpage that includes links to the page in other languages**
    *   The text of each link is the name of the language, in that language. Ensure that the language of each link is indicated with a `lang` attribute. 

Why
---

An incorrect `lang` attribute can negatively impact screen reader software, which relies on the `lang` attribute to apply the correct pronunciation and reading rules. Other tools that rely on proper language designation include translation software and spellcheck and grammar tools.

Who
---

### Affected users

This check affects users who have:

*   Blindness or visual impairments: Who use assistive technology such as screen readers, which rely on the `lang` attribute to apply the correct pronunciation and reading rules.
*   No impairments: Who use translation software, which relies on  the `lang` attribute to apply the correct language pronunciation, and spellcheck and grammar tools, which rely on the  `lang` attribute to apply appropriate spellcheck and grammar rules.

Examples
--------

This section provides some pass and fail examples.

### Pass examples

*   **The correct language for the entire page is specified**
    
        <html lang="en">
        <head>
          <title>Welcome</title>
        </head>
        <body>
          <p>Hello, how are you?</p>
        </body>
        </html>
    
    *   Why this works:
        *   The declared `lang="en"` attribute matches the language of the page.
*   **A section in a different language is correctly specified**
    
        <p lang="fr">Bonjour, comment ça va ?</p>
    
    *   Why this works:
        *   The `lang="fr"` attribute matches the French text.
        *   Screen readers use the correct pronunciation for French.

### Fail examples

*   **The wrong language is declared for the content**
    
        <p lang="de">Hola, ¿cómo estás?</p>
    
    *   Issue:
        *   The text is in Spanish but it is marked with `lang="de"`, which is German.
        *   A screen reader incorrectly uses the German pronunciation rules.
    *   Fix:
        
            <p lang="es">Hola, ¿cómo estás?</p>
        
        *   The correct language `lang="es"` is applied.
*   **A missing language attribute for multilingual content**
    
        <p>Welcome! <span>Bienvenido!</span></p>
    
    *   Issue:
        *   The `lang` attribute to indicate the Spanish text is missing.
    *   Fix:
        
            <p>Welcome! <span lang="es">Bienvenido!</span></p>
        
        *   The Spanish text is correctly identified.

How
---

This section provides instructions on how to review and fix this issue.

### How to review it

1.  Identify language changes within the webpage.
2.  Check if the `lang` attribute is applied to sections where the language changes.
3.  Confirm that the declared `lang` value matches the actual language of the text.
4.  Test with assistive technologies to verify the pronunciation.

### How to fix it

*   Ensure that the primary language of the page is correctly declared in the `<html>` tag.
    
    *   Example: `<html lang="en">`
*   Use `lang` attributes for content in different languages
    
    *   Example: `<span lang="fr">Bonjour</span>`
*   Test the page with a screen reader to verify the pronunciation.
    

Additional resources
--------------------

For information about language tags and how to find out the correct tag, visit the following article:

[Language tags in HTML and XML](https://www.w3.org/International/articles/language-tags/)

### WCAG success criteria

[3.1.2 Language of Parts](https://www.w3.org/WAI/WCAG21/Understanding/language-of-parts)