There are two ways you can add some content in here.
The first is to use an img
element with an appropriate alt
attribute value, e.g.
<a href="path/to/shopping/cart" >
<img src="url/source.jpg" alt="View 3 items in your shopping card" />
</a>
A second method would be to add some text into the i
element and visibly hiding it:
<a href="path/to/shopping/cart">
<i class="fa fa-shopping-cart" aria-hidden="true">
<span class="sr-only">
View 3 items in your shopping cart
</span>
</i>
</a>
Add the .sr-only
class to your stylesheet:
.sr-only {
height: 1px;
width: 1px;
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
position: absolute;
}
This second method will allow for longer strings of text, if needed. It also prevents a quirk on some browsers (Firefox, from memory) where if text is aligned off-screen and is part of a link, a user tabbing to the link sees focus extended to where the text is, which leads to a very long, thin box on screen.
.sr-only
works by making the content a small 1px box that's then clipped out, and for robustness is positioned absolutely on the page. It's supported by all modern browsers and only needs one extra clip rule for older versions of IE that don't like the standard syntax (clip: rect(1px 1px 1px 1px)
). More information can be found on Yahoo's developer blog.
As for which to go for it's a matter of personal preference. I would go for the .sr-only
to add meaningful text to the page if using an icon set. If you want to use the img
element you need to make sure that when the content's updated the content author writes something meaningful rather than describing what the image looks like.