Be careful when you use the aria-label, aria-labelledby, and aria-describedby attributes, because they do not work consistently with all HTML elements. This is a short note on when (and when not) to use those attributes.
The aria-label and aria-labelledby attributes can be used to give an element an accessible name. The aria-describedby attribute can be used to give an element an accessible description. Not all elements can be given an accessible name and/or description though.
The aria-label, aria-labelledby, and aria-describedby attributes can be used with:
- interactive elements like
a(when thehrefattribute is present),audioandvideo(when thecontrolsattribute is present),input(unless they are oftype="hidden"),select,button, andtextarea - elements that have a landmark role – either implicit (
header,footer,main,nav,aside,section, andform) or explicitly set via theroleattribute - elements that have an explicit widget role applied using the
roleattribute – there are 27 widget roles in ARIA 1.1, includingdialog,slider,progressbar, andtooltip iframeandimgelements
If you use aria-label, aria-labelledby, or aria-describedby with any other elements (like div, span, p, blockquote, or strong etc.), they generally won’t work across all browser/assistive technology combinations.
For more information on this, and on using ARIA with HTML in general, refer to the W3C Note on Using ARIA.