Skip to content

no-redundant-role

Reports a role on an element that already has that role by its name (<nav role="navigation">, <button role="button">, <ul role="list">).

The role adds nothing and can only fall out of step with the element: when the element is later changed to another one, the old role overrides the native meaning.

To fix, remove the role.

Reported
<!DOCTYPE html>
<title>x</title>
<nav role="navigation"></nav>
<button role="button">x</button>
<a href="x" role="link">x</a>
<a role="link">x</a>
<ul role="list"></ul>
<div role="navigation"></div>
...
<p role="none"></p>
angular:
lint:
rules:
no-redundant-role: warn # off (default), warn, error
html:
lint:
rules:
no-redundant-role: warn # off (default), warn, error
svelte:
lint:
rules:
no-redundant-role: warn # off (default), warn, error
vue:
lint:
rules:
no-redundant-role: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended.

Suppress one line with sudsy-disable-next-line no-redundant-role in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-eslint no-redundant-role full
html-validate no-redundant-role partial the roles of 19 elements that always have the role, and img with a non-empty alt; the conditional implicit roles (<input> by type, <select>, <li>, <section>) are not checked