Skip to content

noStaticElementInteractions (HTML)

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

Require an appropriate role when a non-interactive element has event handlers.

Elements such as <div> and <span> have no built-in interactive meaning. Adding a mouse, keyboard, or focus handler does not tell assistive technologies that the element behaves like a control. Prefer a native interactive element such as <button>. When that is not possible, add an appropriate ARIA role so the control’s purpose can be announced.

<div onclick="myFunction()"></div>
code-block.html:1:1 lint/a11y/noStaticElementInteractions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected event handler on static element.

> 1 │ <div onclick="myFunction()"></div>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Static elements should not be interactive. To add interactivity such as a mouse or key event listener to a static element, give the element an appropriate role value.

<span onclick="myFunction()"></span>
code-block.html:1:1 lint/a11y/noStaticElementInteractions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected event handler on static element.

> 1 │ <span onclick="myFunction()"></span>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Static elements should not be interactive. To add interactivity such as a mouse or key event listener to a static element, give the element an appropriate role value.

An <a> element without an href attribute is non-interactive.

<a onclick="myFunction()"></a>
code-block.html:1:1 lint/a11y/noStaticElementInteractions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected event handler on static element.

> 1 │ <a onclick="myFunction()"></a>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Static elements should not be interactive. To add interactivity such as a mouse or key event listener to a static element, give the element an appropriate role value.

<div role="button" onclick="myFunction()"></div>
<span role="scrollbar" onclick="myFunction()"></span>
<a href="http://example.com" onclick="myFunction()"></a>

Custom components are not checked.

<TestComponent onclick={doFoo} />