ARIA roles describe what an element is or what it does. They do not cause browsers to provide keyboard behaviors or styling. ARIA roles are added via role="*TYPE*"
. ARIA role does not change for an element after it is set.
There are six categories of ARIA roles:
The landmark roles are:
<header>
.<aside>
.<footer>
.<main>
.<nav>
<section>
element will automatically communicate a section has a role of region if it is given an accessible name.As you may have noticed, most of the landmark roles have equivalent HTML tags. Whenever possible, it is best to use the HTML markup. I've often seen both the HTML tag and the landmark roles used, for example <header role="banner">
, this is technically allowed but it's unnecessary.
Every element with a region role should include a label that describes the purpose of the content in the region. Preferably with an aria-labelledby
attribute referencing a visible header. If no visible appropriate header is present, use aria-label
.
Document Structure roles are used to provide a structural description for a section of content. Most of these roles are now supported by semantic HTML elements with the same meaning, so they should no longer be used. These are not currently available as equivalent native HTML tags:
The various widget roles are used to define common interactive patterns. Similar to the document structure roles, some of these roles duplicate the semantics of native HTML elements that are well supported, and should not be used. The difference between the two is that, generally, the widget roles require JavaScript interaction and the document structure does not necessarily.
Window roles define sub-windows to the main document window, within the same window, such as pop up modal dialogs:
Live region roles are used to define elements with content that will be dynamically changed. Sighted users can see dynamic changes when they are visually noticeable. These roles will help assistive technology users to know if some content has been updated. Assistive technologies can be made to announce dynamic content changes:
Abstract roles are only intended for use by browsers to help organize and streamline a document. They should not be used by developers writing HTML markup. Doing so will not result in any meaningful information being conveyed to assistive technologies or to users.
You add an ARIA role with the role attribute:
<div role="menuitem">Text</div>