WCAG 3.1.2: Language of Parts

WCAG 3.1.2 Language of Parts: Identifying Language Changes for Accessibility

WCAG (Web Content Accessibility Guidelines) Success Criterion 3.1.2, titled "Language of Parts," is a crucial component of ensuring web content is accessible to all users. This criterion requires that when the language of a passage or phrase within a document differs from the default language of the surrounding content, it must be programmatically identified. This enables assistive technologies to accurately interpret and present the content to users.

Why Language of Parts Matters for Accessibility

The ability to programmatically determine the language of specific parts of a web page is fundamental for a truly inclusive user experience. Its impact spans several user groups and aspects of accessibility:

  • Screen Reader Users: For users relying on screen readers, correctly identified language changes mean that the screen reader can switch to the appropriate pronunciation rules and voices. Without this, foreign words or phrases would be mispronounced, making the content difficult or impossible to understand. Imagine a screen reader trying to pronounce a French phrase using English phonetic rules – it would sound like gibberish.
  • Users of Translation Tools: Many users, particularly those with cognitive or learning disabilities, or non-native speakers, rely on browser extensions or built-in tools for translation. When language changes are programmatically marked, these tools can accurately identify and translate only the specific foreign text, rather than attempting to translate the entire page or missing the foreign segments altogether.
  • Users with Cognitive and Learning Disabilities: Clear and accurate presentation of content reduces cognitive load. Mispronounced words or incorrect translations can cause confusion, frustration, and hinder comprehension for users who may already struggle with processing information.
  • Users Who Are Deaf or Hard of Hearing: While not directly impacting auditory perception, accurate language identification can ensure that captions, transcripts, and sign language interpretations (if provided) correctly reflect the spoken language, especially in multimedia content where different languages might be spoken.

By meeting this criterion, you enhance the comprehensibility, usability, and overall quality of your web content for a diverse audience.

Success Criterion 3.1.2 Language of Parts (Level AA) Requirements

The official wording for Success Criterion 3.1.2 is:

The human language of each passage or phrase in the content can be programmatically determined except for proper names, technical terms, words whose language is ambiguous, and words or phrases that have become part of the vernacular of the immediately surrounding text.

Key Aspects and Interpretations:

  • "Human language": Refers to natural languages (e.g., English, French, Japanese) as opposed to programming languages or markup.
  • "Passage or phrase": This implies that individual words, sentences, or entire paragraphs that differ in language from the main text need to be identified. The granularity depends on the extent of the language change.
  • "Programmatically determined": This is crucial. It means the language information must be embedded in the code (e.g., HTML, XML) in a way that assistive technologies can read and understand it, not just visually indicated (like using italics or a different font color).
  • Exceptions: The criterion provides specific exceptions where programmatic identification is not required:
    • Proper names: Names of people, places, or brands (e.g., "Juan" in an English text).
    • Technical terms: Specific jargon or terms unique to a field (e.g., "déjà vu" in a psychological text, if it’s treated as a technical term).
    • Words whose language is ambiguous: Words that exist in multiple languages with the same spelling and often similar meaning (e.g., "chef" in English and French).
    • Words or phrases that have become part of the vernacular: Commonly used foreign words that are widely understood and assimilated into the primary language of the surrounding text (e.g., "status quo," "ad hoc," "kindergarten" in English). Judgment is required here to determine if a word is truly part of the vernacular for the target audience.

Practical Guidelines for Compliance

The primary method for meeting Success Criterion 3.1.2 in HTML content is by using the lang attribute. The lang attribute can be applied to any HTML element to specify the language of its content and any nested elements within it, unless overridden by a nested lang attribute.

Using the lang Attribute:

  1. Identify Language Changes: Carefully review your content for any words, phrases, or passages that are in a different human language than the main content.
  2. Apply the lang Attribute: Enclose the foreign content within an appropriate HTML element (like <span> for inline text or <p>, <blockquote>, <div> for block-level content) and add the lang attribute with the correct ISO 639-1 language code.
  3. Use Correct Language Codes: Ensure you use valid and appropriate ISO 639-1 two-letter codes for the language (e.g., en for English, fr for French, es for Spanish, de for German, ja for Japanese, zh for Chinese). For regional variations, you can use a hyphenated code (e.g., en-US for American English, en-GB for British English).

Examples

Correct Implementations:

Our team often uses the phrase c’est la vie to express acceptance of a situation.

During the meeting, she frequently used the term Gestalt to describe the unified whole.

«El ingenioso hidalgo Don Quijote de la Mancha» es una de las obras más destacadas de la literatura española.

This Spanish quote is properly marked with lang="es".

This paragraph is primarily in English, but it contains a sentence in Japanese: 日本語の文章です。

Incorrect Implementations:

In these examples, the language change is either not marked or only indicated visually, making it inaccessible to assistive technologies.

Our team often uses the phrase c’est la vie to express acceptance of a situation.

(Problem: Only visual styling (italics) is used; no programmatic identification.)

During the meeting, she frequently used the term Gestalt to describe the unified whole.

(Problem: No programmatic identification, even if visually different.)

This paragraph is primarily in English, but it contains a sentence in Japanese: 日本語の文章です。

(Problem: A custom data-* attribute is not a standard way to programmatically determine language for WCAG; the lang attribute must be used.)

Best Practices and Common Pitfalls

Best Practices:

  • Be Thorough: Review all content for foreign words, phrases, and passages. This is especially important for multilingual sites or content that frequently quotes foreign sources.
  • Use the Smallest Applicable Element: Apply the lang attribute to the smallest HTML element that fully encompasses the foreign content (e.g., <span> for a few words, <p> for a paragraph, <blockquote> for a quote).
  • Validate Language Codes: Always use valid IETF BCP 47 language tags (which includes ISO 639-1).
  • Content Author Training: Educate content creators and editors on the importance of this criterion and how to correctly apply language markup.
  • Automated and Manual Testing: Use automated accessibility checkers for initial scans and conduct manual reviews, especially with screen readers, to verify correct pronunciation.
  • Dynamic Content: If content is loaded dynamically (e.g., via JavaScript/AJAX), ensure that the `lang` attribute is correctly applied to the newly inserted elements.

Common Pitfalls:

  • Forgetting to Mark Up: The most common issue is simply overlooking language changes within text.
  • Relying on Visual Cues Only: Using italics, bolding, or a different font color to indicate foreign text is not sufficient for programmatic determination.
  • Incorrect Language Codes: Using misspelled codes (e.g., frn instead of fr) or codes for regions instead of languages (e.g., us instead of en-US or en).
  • Overuse for Vernacular Terms: Applying lang to every single foreign word, even those commonly accepted into the primary language (like "café" or "rendezvous" in English), can be unnecessary and sometimes disruptive for screen readers. Judgment is key here, considering the target audience.
  • Mixing Languages in One Element Without Marking: If a sentence switches back and forth between languages, each segment needs its own `lang` attribute within a `span` or similar element.

Conclusion

WCAG 3.1.2 Language of Parts is a relatively straightforward criterion to implement, but its impact on accessibility is profound. By ensuring that all language changes within your web content are programmatically identified using the lang attribute, you empower assistive technologies to accurately interpret and convey your message. This attention to detail significantly improves the experience for screen reader users, those using translation tools, and individuals with cognitive disabilities, making your content truly accessible and inclusive.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.