html-has-lang
Configuration
Rule Details
This rule enforces that every <html> element carries a truthy lang prop.
Screen readers and assistive technology rely on the document language to
pronounce content correctly; an <html> element without a usable lang
value violates WCAG 3.1.1.
The element name is resolved through the standard jsx-a11y settings —
components and polymorphicPropName — so a custom component mapped to
html (e.g. <HTMLTop /> with settings: { 'jsx-a11y': { components: { HTMLTop: 'html' } } })
is checked the same way as a literal <html> tag.
The lang prop is considered present when its value extracts to a JS-truthy
value via getPropValue. Notably, <html lang /> is treated as truthy
(boolean true); <html lang={undefined} /> is falsy and reported.
This rule is largely superseded by the lang rule,
which additionally validates that the value is a recognized BCP-47 language tag.
Examples of incorrect code for this rule:
Examples of correct code for this rule: