Icons are symbols that can convey a ton of information and really help people comprehend directions, signs, and interfaces. Its important that we create and use them so that they can reach the largest amount of people possible.
When creating web sites and apps, that means making sure our icons play well with assistive tech when users are navigating apps and sites.
Modern versions of assistive technology, like screen readers, will read CSS generated content (how Font Awesome icons are rendered), as well as specific Unicode characters. When trying our default markup for rendering icons, assisistive technology may have the following problems.
When using icons in your UI, there are ways to help assistive technology either ignore or better understand Font Awesome.
If you're using an icon to add some extra decoration or branding, it does not need to be announced to users as they are navigating your site or app aurally. Additionally, if you're using an icon to visually re-emphasize or add styling to content already present in your HTML, it does not need to be repeated to an assistive technology-using user. You can make sure this is not read by adding the aria-hidden="true"
to your Font Awesome markup.
<i class="fa fa-fighter-jet" aria-hidden="true"></i>
<h1 class="logo">
<i class="fa fa-pied-piper" aria-hidden="true"></i>
Pied Piper, A Middle-Out Compression Solution Making Data Storage Problems Smaller
</h1>
<a href="https://github.com/FortAwesome/Font-Awesome"><i class="fa fa-github" aria-hidden="true"></i> View this project's code on Github</a>
If you're using an icon to convey meaning (rather than only as a decorative element), ensure that this meaning is also conveyed to assistive technologies. This goes for content you're abbreviating via icons as well as interactive controls (buttons, form elements, toggles, etc.). There are a few techniques to accomplish this:
If not representing an interactive element, like a button or link, use both a title
attribute and an on the icon to provide a text alternative. This has the advantages of working with all modern screen readers, working well with the most ubiquitous speech recognition program, and helping users with cognitive disabilities by providing a mouse tooltip.
<dl>
<dt>
<i class="fa fa-car" aria-hidden="true"></i>
<span class="sr-only">Time to destination by car:</span>
</dt>
<dd>4 minutes</dd>
<dt>
<i class="fa fa-bicycle" aria-hidden="true"></i>
<span class="sr-only">Time to destination by bike:</span>
</dt>
<dd>12 minutes</dd>
</dl>
<i class="fa fa-hourglass" aria-hidden="true"></i>
<span class="sr-only">60 minutes remains in your exam</span>
<i class="fa fa-hourglass-half" aria-hidden="true"></i>
<span class="sr-only">30 minutes remains in your exam</span>
<i class="fa fa-hourglass-end" aria-hidden="true"></i>
<span class="sr-only">0 minutes remains in your exam</span>
In addition to the recommendations above, use a title
attribute which makes the accessible text discoverable by mouse and those with cognitive disabilities.
<a href="path/to/shopping/cart">
<i class="fa fa-shopping-cart" title="View 3 items in your shopping cart" aria-hidden="true"></i>
<span class="sr-only">View 3 items in your shopping cart</span>
</a>
<a href="#navigation-main">
<i class="fa fa-bars" title="Skip to main navigation" aria-hidden="true"></i>
<span class="sr-only">Skip to main navigation</span>
</a>
<a class="btn btn-danger" href="path/to/settings">
<i class="fa fa-trash-o" title="Delete" aria-hidden="true"></i>
<span class="sr-only">Delete</span>
</a>
While the scenarios and techniques above help avoid some serious issues and confusion, they are not exhaustive. There are many complex contexts and use cases when it comes to accessibility, such as users with low quality vision using high contrast mode to better see UI. There are some great tools and resources to learning and work on these out there. Here are a few reads we recommend.
We'll continue to work on these under the larger topic of accessibility, but in the meantime, let us know if any bugs or issues.