Skip to content

Accessibility: Using ARIA roles

ARIA roles provide semantics to elements that do not have them natively, such as a div used as a button. Always prefer native semantic HTML elements, but when that is not possible, ARIA can fill the gaps for assistive technologies.

<div
  role="button"
  tabindex="0"
  onclick="handleAction()"
  onkeydown="(event) => { if(event.key === 'Enter' || event.key === ' ') handleAction() }"
>
  Click Me
</div>

<div role="navigation">
  <ul>
    <li><a href="/">Home</a></li>
  </ul>
</div>

1 Comment

Leave a Comment

Your email address will not be published.