Skip to content

useSemanticElements

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

Enforces using semantic DOM elements over the ARIA role property.

The role attribute is used to define the purpose of an element, but it should be used as a last resort. Using semantic elements like <button>, <nav> and others are more accessible and provide better semantics.

<div role="checkbox"></div>
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with this role can be changed to the following elements:
<input type=“checkbox”>

> 1 │ <div role=“checkbox”></div>
^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

Replace with one of these elements:

- <input type=“checkbox”>

<div role="separator"></div>
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with this role can be changed to the following elements:
<hr>

> 1 │ <div role=“separator”></div>
^^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

Replace with one of these elements:

- <hr>

<div role="checkbox" />
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with this role can be changed to the following elements:
<input type=“checkbox”>

> 1 │ <div role=“checkbox” />
^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

Replace with one of these elements:

- <input type=“checkbox”>

<div role="separator" />
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with this role can be changed to the following elements:
<hr>

> 1 │ <div role=“separator” />
^^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

Replace with one of these elements:

- <hr>

<>
<input type="checkbox">label</input>
<hr/>
<div role="status"></div>
</>;

All elements with role="img" are ignored:

<div role="img" aria-label="That cat is so cute">
<p>&#x1F408; &#x1F602;</p>
</div>

Semantic elements with a matching role are not flagged (see noRedundantRoles):

<>
<nav role="navigation"></nav>
<footer role="contentinfo"></footer>
</>;