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 reading our default markup for rendering icons, assisistive technology may have the following problems.
<p>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 <code>aria-hidden="true"</code> to your Fork Awesome markup.</p>
Pied Piper, A Middle-Out Compression Solution Making Data Storage Problems Smaller
<spanclass="nt"></h1></span>
</code></pre></div>
<smallclass="text-muted">an icon being used as a logo</small>
</div>
<divclass="margin-bottom-lg">
<divclass="highlight"><pre><codeclass="html"><spanclass="nt"><a</span><spanclass="na">href=</span><spanclass="s">"https://github.com/FortAwesome/Font-Awesome"</span><spanclass="nt">><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-github"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="nt">></i></span> View this project's code on Github<spanclass="nt"></a></span>
</code></pre></div>
<smallclass="text-muted">an icon being used in front of link text</small>
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:
The simplest way to provide a text alternative is to use the <code>aria-hidden="true"</code> attribute on the icon and to include the text with an additional element, such as a <code><span></code>, with appropriate CSS to visually hide the element while keeping it accessible to assistive technologies. In addition, you can add a <code>title</code> attribute on the icon to provide a tooltip for sighted mouse users.
<spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-car"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"Time to destination by car"</span><spanclass="nt">></i></span>
<spanclass="nt"><span</span><spanclass="na">class=</span><spanclass="s">"sr-only"</span><spanclass="nt">></span>Time to destination by car:<spanclass="nt"></span></span>
<spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-bicycle"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"Time to destination by bike"</span><spanclass="nt">></i></span>
<spanclass="nt"><span</span><spanclass="na">class=</span><spanclass="s">"sr-only"</span><spanclass="nt">></span>Time to destination by bike:<spanclass="nt"></span></span>
<divclass="highlight"><pre><codeclass="html"><spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-hourglass"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"60 minutes remain in your exam"</span><spanclass="nt">></i></span>
<spanclass="nt"><span</span><spanclass="na">class=</span><spanclass="s">"sr-only"</span><spanclass="nt">></span>60 minutes remain in your exam<spanclass="nt"></span></span>
<spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-hourglass-half"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"30 minutes remain in your exam"</span><spanclass="nt">></i></span>
<spanclass="nt"><span</span><spanclass="na">class=</span><spanclass="s">"sr-only"</span><spanclass="nt">></span>30 minutes remain in your exam<spanclass="nt"></span></span>
<spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-hourglass-end"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"0 minutes remain in your exam"</span><spanclass="nt">></i></span>
<spanclass="nt"><span</span><spanclass="na">class=</span><spanclass="s">"sr-only"</span><spanclass="nt">></span>0 minutes remain in your exam<spanclass="nt"></span></span>
In the case of focusable interactive elements, there are various options to include an alternative text or label to the element, without the need for any visually hidden <code><span></code> or similar. For instance, simply adding the <code>aria-label</code> attribute with a text description to the interactive element itself will be sufficient to provide an accessible alternative name for the element. If you need to provide a visual tooltip on mouseover/focus, we recommend additionally using the <code>title</code> attribute or a <ahref="https://github.com/chinchang/hint.css">custom tooltip</a> solution.
<divclass="highlight"><pre><codeclass="html"><spanclass="nt"><a</span><spanclass="na">href=</span><spanclass="s">"path/to/shopping/cart"</span><spanclass="na">aria-label=</span><spanclass="s">"View 3 items in your shopping cart"</span><spanclass="nt">></span>
<divclass="highlight"><pre><codeclass="html"><spanclass="nt"><a</span><spanclass="na">href=</span><spanclass="s">"#navigation-main"</span><spanclass="na">aria-label=</span><spanclass="s">"Skip to main navigation"</span><spanclass="nt">></span>
<spanclass="nt"><i</span><spanclass="na">class=</span><spanclass="s">"fa fa-trash-o"</span><spanclass="na">aria-hidden=</span><spanclass="s">"true"</span><spanclass="na">title=</span><spanclass="s">"Delete this item?"</span><spanclass="nt">></i></span>
While the scenarios and techniques here 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 vision who need a high color contrast ratio to see UI. There are some great tools and resources to learn from and work on these issues 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, <ahref="../community/#reporting-bugs">let us know if any bugs or issues</a>.