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", setxml:lang="en"as well. - Remove
xml:langif you don't need it. For HTML5 documents served astext/html, thelangattribute alone is sufficient.xml:langis only required for XHTML documents served asapplication/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.