We'd like to set Google Analytics cookies to learn how people use the Knowledge Base, so we can improve it. We set them only if you accept.

Skip to main content
Digital Accessibility Knowledge Base

valid-lang

Web validation

The lang attribute’s value must be a valid ISO 639 language tag.

Sometimes pages contain content in more than one language. A lang attribute on a specific element tells browsers and assistive technology which language engine to load for it, so text is pronounced and parsed correctly. An invalid tag such as lang="english" falls outside the ISO 639 list and cannot be interpreted reliably. When language metadata is wrong or missing, assistive technology may misread the content of the element, confusing people who rely on speech output.

Pass Patterns

A page in English with a specific part that is written in Spanish

The document’s root element uses the two-letter tag en, and the Spanish phrase is correctly marked with lang="es". Both tags appear in ISO 639-1.

HTML
<!DOCTYPE html>
<html lang="en">
    <head>…</head>
    <body>
        <p>Welcome!</p>
        <p lang="es">¡Hola!</p>
    </body>
</html>

Specifying a dialect

fr-CA on the second paragraph identifies Canadian French, a valid subtag combination that helps screen readers switch voices automatically.

HTML
<!DOCTYPE html>
<html lang="en">
    <head>…</head>
    <body>
        <p>Hello world!</p>
        <p lang="fr-CA">Bonjour tout le monde!</p>
    </body>
</html>

Fail Patterns

Invalid dialect subtag separator

The separator between the language tag and its dialect subtag must be a hyphen (-). Using an underscore makes the language tag invalid.

HTML
<!DOCTYPE html>
<html lang="fr">
    <head>…</head>
    <body>
        <p>Bonjour tout le monde!</p>
        <p lang="en_GB">Hello world!</p>
    </body>
</html>

Invalid language value due to a nonexistent language tag

english is not an ISO 639 code, so the user agent cannot map it to a language engine.

HTML
<!DOCTYPE html>
<html lang="es">
    <head>…</head>
    <body>
        <p>¡Hola!</p>
        <p lang="english">Welcome!</p>
    </body>
</html>

ACT Rules

Try It Yourself

Screen readers read and pronounce text in different languages based not only on the lang attribute, but also on the installed language packages and the operating system’s default language. To ensure consistent test results across all users, the tests will focus on validating allowed lang values from Set 1 of the ISO 639 standard.

Inspecting the browser dev-tools

  1. Open the page in a browser.
  2. Open Developer Tools and switch to the Elements panel.
  3. Select the element with the specific lang attribute (not the html tag which defines the language of the entire page).

Expected result: The primary language subtag of the element’s lang value (for example, fr in fr-CA) is included in the ISO 639 list.

Actual result: The value of the element’s lang attribute is not included in the ISO 639 list.

FAQ

How does this issue relate to 3.1.2 Language of Parts?

SC 3.1.2 requires that each passage written in a different language be programmatically identified. Invalid or absent lang values break that linkage, so assistive technology cannot shift to the right pronunciation library.

Why is this issue marked as Serious?

Mislabeling language stops speech engines from switching voices, which can render entire passages unintelligible for screen-reader users and anyone who depends on text-to-speech. Because it blocks comprehension rather than merely slowing it, the impact is considered serious across major browsers and assistive technologies.

Standards and Regulations

StandardSuccess CriterionReference
WCAG 2.23.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 5499.3.1.2 Language of PartsSame as the WCAG text.

Personas impacted by this issue