-
Should all elements on a page have aria-labels? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Short answer: alt-text can be used only with images, while aria-labels can be applied to pretty much everything. Only use aria-labels on images if for some reason you can't use alt-text. And No, all elements shouldn't be using aria-labels. Longer answer: Page elements should only have aria-labels associated with them if for whatever reason you cannot provide the equivalent semantics with HTML. The first rule of ARIA is not to use ARIA. If you can't do:
You could do something like this: But why not just stick to the classic form which will be more accessible across a broader range of devices (especially older Assistive Technology). WAI's Accessible Rich Internet Applications (ARIA) was designed for dynamic content which HTML just wasn't designed for. Interactive states like whether a box is expanded/collapsed cannot be communicated in HTML. Nor can things like alerts or page regions. Google's got a good description of difference between aria-label & labelledby and aria-describedby. Think of ARIA like salt, remember it is best used in moderation. Duplicating content does not make it more accessible, but can actually reduce the usability of your site for people with disabilities. Many sites actually become less accessible because developers threw in ARIA & overwrote the semantics that was being provided by HTML. |
Beta Was this translation helpful? Give feedback.
-
Another example of using aria, in this case, Because the search results are dynamic we want to let the screen readers know that results have been added after typing a search term. |
Beta Was this translation helpful? Give feedback.
Short answer: alt-text can be used only with images, while aria-labels can be applied to pretty much everything. Only use aria-labels on images if for some reason you can't use alt-text.
And No, all elements shouldn't be using aria-labels.
Longer answer: Page elements should only have aria-labels associated with them if for whatever reason you cannot provide the equivalent semantics with HTML. The first rule of ARIA is not to use ARIA.
If you can't do:
You could do something like this:
<div role="button" aria-label="Add to favorites">
But why not just stick to the classic form which will be more accessibl…