ARIA
ARIA stands for Accessible Rich Internet Applications. It's a set of attributes that can be added to HTML elements with goal of improving the website accessibility by clearly communicating role, state or other properties of the element.
ARIA landmark roles
Identify the purpose the element serves, more than just the element tag.
role="banner"
contains main heading/title of the page — used onheader
element. One per page.role="complementary"
— additional section of the page, used onaside
elementrole="contentinfo"
— element that contains additional information about the document content. One per page, typically on afooter
elementrole="form"
— element that contains form control; do not use on actualform
element, but rather on containers for standalone controlsrole="main"
the main content of the component; usually on themain
element. One per pagerole="navigation"
contains links/other navigation elements. Usually onnav
elementrole="search"
search for the document; typically a form
Other ARIA role attributes
role="button"
mark elements other than<button>
as buttons. Sometimes useful- Elements marked with this role can also use
aria-pressed
attribute to signify the button state (ie. toggle buttons) - should have
aria-label
oraria-labelledby
attribute, especially if content doesn’t describe the action well (ie. close button with ‘x’ as a content)
- Elements marked with this role can also use
role=“combobox”
,role=“listbox”
mark elements that allow to select options, that are not standard<select>
— ie. typeahead, custom dropdown implementationrole=“option”
use within the above; mark an option of a custom dropdown.role=“dialog”
custom modalsrole=“checkbox”
,role=“radio”
custom elements that represent checkboxes and radio buttons.aria-checked
attribute to provide the state of the elementrole=“toolip”
Further reading
- The Roles Model | Accessible Rich Internet Applications (WAI-ARIA) 1.0
- Using ARIA - Accessibility | MDN
- Using the aria-label attribute - Accessibility | MDN
- Using the aria-labelledby attribute - Accessibility | MDN
- Using the button role - Accessibility | MDN
- How to Use ARIA Effectively with HTML5 — SitePoint