Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font Awesome accessibility issue. Use <em> tags instead of <i>

I am testing my HTML code markup compliance with accessibility standards: http://achecker.ca/checker/index.php. The following is an error I get:

Repair: Replace your i elements with em or strong.

<i class="fa fa-search" title="Search"></i> <span class="sr-only">Search</span>

I went through the official Font Awesome docs on the accessibility (https://cdn.fontawesome.com/help#qa-autoa11y), and didn't find any mention of that I need to use different tags for icons. Any ideas on this?

like image 958
sdvnksv Avatar asked Oct 26 '16 14:10

sdvnksv


People also ask

Why is I tag used for Font Awesome?

It is because they are both inline elements. <i> is shorter to type than <span> and the icon won't get rendered in italics.

Why do some Font Awesome icons not work?

If you installed the Free Font Awesome version but try adding Pro icons to your web pages, they won't show. The solution to this is either you use the alternative free icons or upgrade to a Pro subscription/license.

Is Font Awesome accessible?

Every Kit comes with auto-accessibility built-in and provides the modern and proper syntax assistive technologies recognize. Font Awesome auto-accessibility feature will make sure it is ignored by assistive technology. There's nothing extra you need to on top of how you would usually reference an icon.

What is difference between fa and FAS in Font Awesome?

Instead of fa as a style preceding every icon style, you need to pick from fas for solid, far for regular, fal for light, or fab for brand. It looks like fas is the fallback, so you get solid if you leave your old fa references. For most icons, this change makes the icon heavier or lighter.


1 Answers

As a general guideline, you should use em for emphasis instead of i for italic text because italic text is normally used only to imply emphasis.

In this case, you are using i for icon, which is nonsense (and confusing your accessibility checking tool). Use a span instead. That doesn't come loaded with any inappropriate semantics.

like image 196
Quentin Avatar answered Sep 18 '22 19:09

Quentin