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

html-xml-lang-mismatch

Web validation

If the <html> tag has lang and xml:lang attributes, both attributes must carry the same valid language code.

All pages need a single, reliable primary language indicator. When both lang and xml:lang are present, they have to match so that browsers, search engines, and assistive technology switch to the correct language profile. A mismatch can send a screen reader to the wrong voice, hamper spell-checking, and mislead translation tools.

Pass Patterns

Matching lang and xml:lang values

The lang and xml:lang values are identical and use the two-letter tag en that is part of the ISO 639-1 list.

HTML
<!DOCTYPE html>
<html lang="en" xml:lang="en">
    <head>
        <meta charset="utf-8">
        <title>Matching language codes</title>
    </head>
    <body>
        …
    </body>
</html>

Fail Patterns

lang and xml:lang values do not match

lang and xml:lang exist but disagree, forcing assistive technology to guess which one is right.

HTML
<!DOCTYPE html>
<html lang="en" xml:lang="fr">
    <head>
        <meta charset="utf-8">
        <title>Mismatching language codes</title>
    </head>
    <body>
        …
    </body>
</html>

Try It Yourself

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 root <html> element and look at the lang and xml:lang attributes.

Expected result: Both the lang and xml:lang attributes carry the same value.

Actual result: The lang and xml:lang attributes have different values.

FAQ

How does this issue relate to 3.1.1 Language of Page?

SC 3.1.1 requires that the page’s default human language be programmatically determinable. When lang and xml:lang disagree, user agents cannot tell which value to trust, so the success criterion fails.

Why is this issue marked as Moderate?

Most modern screen readers default to the user’s language when codes conflict, so content remains somewhat usable. However, pronunciation, hyphenation, and dictionary support are often wrong, which slows comprehension and increases cognitive load, especially for multilingual users, so the impact is more than minor but short of severe.

Standards and Regulations

StandardSuccess CriterionReference
WCAG 2.23.1.1 Language of Page (A)The default human language of each web page can be programmatically determined.
EN 301 5499.3.1.1 Language of PageSame as the WCAG text.

Personas impacted by this issue