Avoid Redundant ARIA Roles

ID

html.redundant_role

Severity

info

Remediation Complexity

low

Remediation Risk

low

Remediation Effort

low

Resource

Code Smell

Language

Html

Tags

code_smell

Description

Flags an element whose explicit role attribute merely restates the implicit ARIA role the element already has.

Rationale

Native HTML elements carry an implicit ARIA role: a <nav> is already a navigation landmark, a <button> already exposes the button role, and so on. Writing role="navigation" on a <nav> adds nothing, is extra markup to maintain, and risks drifting out of sync if the element is later changed.

<nav role="navigation">...</nav>   <!-- FLAW — nav already has the navigation role -->

<nav role="menubar">...</nav>      <!-- OK — role differs from the implicit one -->
<div role="button">...</div>       <!-- OK — div has no implicit role -->

Remediation

Remove the role attribute when it duplicates the element’s implicit role; keep it only when it intentionally overrides the native semantics.