3.1.2 Language of Parts
Introduction¶
This check states that webpages with sections of text in different languages must have an associated lang
attribute for each language. Examples include:
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.
For example, if a section of a webpage contains the French text, it must have lang="fr"
applied.
Why¶
This section provides information about why this check is important. In addition, it includes some pass and fail examples.
An incorrect lang
attribute can negatively impact:
- Screen readers
- They rely on the
lang
attribute to apply the correct pronunciation and reading rules.
- Translation tools
- Automated translation services may not detect the correct language, which leads to poor translations.
- Spellcheck and grammar tools
- Many assistive technologies use the
lang
attribute to apply appropriate spellcheck and grammar rules.
Examples¶
This section provides some pass and fail examples.
Pass examples¶
Fail examples¶
How¶
This section provides instructions on how to review and fix this issue.
How to review it¶
- Identify language changes within the webpage.
- Check if the
lang
attribute is applied to sections where the language changes. - Confirm that the declared
lang
value matches the actual language of the text. - 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
WCAG success criteria¶
3.1.2 Language of Parts