Back to Learn
Pulseaccessibility

HTML lang and xml:lang Match

What This Audit Checks

This audit verifies that when the <html> element has both a lang and an xml:lang attribute, both values declare the same base language. A mismatch creates conflicting language declarations.

Why It Matters

When lang and xml:lang disagree, different user agents may pick different values. A screen reader could announce content using the wrong language's pronunciation rules, making speech output unintelligible.

How to Fix It

  • Make both attributes identical. If you have lang="en", set xml:lang="en" as well.
  • Remove xml:lang if you don't need it. For HTML5 documents served as text/html, the lang attribute alone is sufficient. xml:lang is only required for XHTML documents served as application/xhtml+xml.
  • Automate with a linter. Catch mismatches during development rather than after deployment.
<!-- Bad: mismatched language declarations -->
<html lang="en" xml:lang="fr">

<!-- Good: matching values -->
<html lang="en" xml:lang="en">

<!-- Best for HTML5: remove xml:lang entirely -->
<html lang="en">

How Pulse Tracks This

Pulse flags this audit in your Lighthouse accessibility score. When the audit fails, Pulse shows which elements triggered it so you can fix them directly.

Resources