Skip to content

useHtmlLang

¥Summary

  • 规则生效日期:v1.0.0

    ¥Rule available since: v1.0.0

  • 诊断类别:lint/a11y/useHtmlLang

    ¥Diagnostic Category: lint/a11y/useHtmlLang

  • 此规则为推荐规则,默认启用。

    ¥This rule is recommended, which means is enabled by default.

  • 此规则没有修复方案。

    ¥This rule doesn’t have a fix.

  • 此规则的默认严重级别为 error

    ¥The default severity of this rule is error.

  • 来源:

    ¥Sources:

¥How to configure

biome.json
{
"linter": {
"rules": {
"a11y": {
"useHtmlLang": "error"
}
}
}
}

¥Description

强制 ARIA 状态和属性值有效。

¥Enforce that html element has lang attribute.

¥Examples

¥Invalid

<html></html>
code-block.jsx: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 languageused by screen readers when no user default is specified.

<html lang={""}></html>
code-block.jsx: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 languageused by screen readers when no user default is specified.

<html lang={null}></html>
code-block.jsx:1:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a lang attribute when using the html element.

> 1 │ <html lang={null}></html>
^^^^^^^^^^^^^^^^^^
2 │

Setting a lang attribute on HTML document elements configures the languageused by screen readers when no user default is specified.

<html lang={undefined}></html>
code-block.jsx:1:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a lang attribute when using the html element.

> 1 │ <html lang={undefined}></html>
^^^^^^^^^^^^^^^^^^^^^^^
2 │

Setting a lang attribute on HTML document elements configures the languageused by screen readers when no user default is specified.

<html lang={true}></html>
code-block.jsx:1:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a lang attribute when using the html element.

> 1 │ <html lang={true}></html>
^^^^^^^^^^^^^^^^^^
2 │

Setting a lang attribute on HTML document elements configures the languageused by screen readers when no user default is specified.

¥Valid

<html lang="en"></html>
<html lang={language}></html>
<html {...props}></html>
<html lang={""} {...props}></html>

¥Accessibility guidelines

¥Related links