In one paragraph
HTML elements with lang and xml:lang must have the same base language identifies conflicting root declarations under this rule. First establish the real content language and whether the document is served as HTML or XML. Correct the authoritative declaration and remove unnecessary duplication where appropriate. A shared base code satisfies this limited comparison, but does not prove full tag consistency, validity, or correct pronunciation.
Why it matters
Language metadata can support pronunciation and other language-sensitive processing, subject to user-agent capabilities and settings. A Czech page labelled English can be difficult to interpret, but two contradictory declarations do not tell you which one is factually wrong.
On ordinary text/html documents, lang is the relevant HTML declaration; legacy XHTML-style templates can carry an unnecessary stale xml:lang copy. XML-serialised documents and foreign-content contexts need their own language rules, so do not delete every xml:lang occurrence blindly.
The checker compares primary language rather than every subtag. en-US and en-GB can therefore pass its shared-base condition even though the declarations are not identical. That does not certify every applicable HTML or XML consistency requirement.
How WebAuditOS evaluates this finding
The supplied html-xml-lang-mismatch rule inspects the root only when both relevant values meet its applicability conditions. It compares their base language with the documented whitespace and case handling. Different base languages fail at medium severity; a matching base satisfies this check.
Missing or invalid declarations can be outside this rule and belong to other language checks. It does not validate every descendant, actual content language, complete BCP 47 tag, or the speech behaviour of every client.
How to fix it
- Inspect the final Content-Type and document syntax as delivered, not just the presence of an XHTML namespace in a template. The response format matters to how language declarations are interpreted.
- Identify the primary human language of the content. Do not select whichever current attribute happens to match a developer's browser setting.
- For a normal Czech HTML page, a suitable root declaration is:
<html lang="cs">
Use the real language and appropriate specificity. An ordinary HTML template often does not need an xml:lang duplicate.
- If the application deliberately maintains both declarations or serves XML, follow the relevant host-language rules and keep values coherent from one maintained source. A shared-base checker pass is not a reason to preserve conflicting full variants.
- Fix multilingual routing or CMS templates so both initial delivery and language changes reflect the current content. Avoid one hard-coded attribute left over from a previous locale.
- Mark meaningful language changes within the page where required, while respecting the language-of-parts exceptions. Correct root metadata alone does not describe every passage.
- Verify tags with an appropriate language reference and test representative assistive output where feasible. Missing voice support can limit the test environment without proving the markup invalid.
- Rescan root presence, validity, and mismatch checks together. Explain differences in their scopes instead of treating one pass as proof all language metadata is correct.
What the fix can break
Deleting xml:lang from an XML-based workflow without review can change intended language processing. Scope the repair to the actual response format and consumer needs.
A translation component can update visible text while leaving document attributes stale. Test in-app navigation as well as direct locale URLs.
Do not promise identical pronunciation everywhere after alignment. Speech engines and accessible-name processing have their own limitations.
Questions
Does en-US versus en-GB fail this comparison?
The supplied rule compares the shared en base, so it passes that comparison. Full consistency still needs review.
Should every xml:lang be deleted?
No. Ordinary HTML and XML contexts differ. Understand the actual document format first.
Does this rule detect a missing root language?
Not by itself. Presence and validity have separate checks.
Which related checks help?
Review root language, valid language values, and language consistency.
What severity does this get in the report?
Medium. An axe finding takes its severity from the impact axe reports for the element that failed, and the report maps critical and serious to high, moderate to medium, minor to low. This rule is declared moderate in axe-core, so a failure arrives as medium.