useHtmlLang (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.4.0 - Diagnostic Category:
lint/a11y/useHtmlLang - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Inspired from
jsx-a11y/html-has-lang - Same as
@html-eslint/require-lang
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "a11y": { "useHtmlLang": "error" } } }}Description
Section titled “Description”Enforce that html element has lang attribute.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<html></html>code-block.html:1:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Provide a lang attribute when using the html element.
> 1 │ <html></html>
│ ^^^^^^
2 │
ℹ Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.
<html lang=""></html>code-block.html:1:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Provide a lang attribute when using the html element.
> 1 │ <html lang=""></html>
│ ^^^^^^^^^^^^^^
2 │
ℹ Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.
<html lang="en"></html>Accessibility guidelines
Section titled “Accessibility guidelines”Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.