Reputation: 2795
I need to use a font awesome icon inside an anchor element. The anchor element does not contain anything rather than the icon.
Ex:
<a href="#" aria-label="List">
<i className="fa fa-list-ul"
title="List View"
aria-hidden="true"
title="List View">
</i>
</a>
What I want to know is is it wrong to put aria-hidden="true" to the icon since there is no other text or content inside the anchor tag(In this case tag becomes informational so I think it is ok to use aria-hidden="false" here).
Is there any rules related to this so we all can follow ?
Upvotes: 0
Views: 3327
Reputation: 18807
You have two things to consider:
people not using assistive technologies (=not relying on ARIA)
What alternative text will have people not using assistive technologies? A title
attribute should be added to the a[href]
tag.
This will help for instance, people with cognitive deficience, people with low vision, people with bad computer knowledge to understand the meaning of the icon. If you can show the tooltip on keyboard focus, it would also be nice.
people using assistive technologies
Do not use role="presentation" or aria-hidden="true" on a visible focusable element
Perfect here, only the a[href]
is focusable. This does not prevent you from adding the aria-hidden
attribute on the i
element as long as you keep an aria-label
for valid alternative for assistive technologies.
Upvotes: 1