Introducing
The first time I realized the use of tag <i></i>
to apply icons, more properly those contained in a font (font), was through Bootstrap.
Some examples are the Fontawesome and the Glyphish that use fonts to provide icons.
I can’t say I agreed with the idea, but at the time, I wasn’t even out of line. It was a "victory" for them in terms of performance (performance):
i
as an icon abbreviation;
- tag with a super small size compared to other.
However, at present, even Bootstrap has left this practice and uses the tag <span></span>
to display icons.
Officially
By what can be read on W3C website, the tag <i></i>
has a well-defined objective:
Although Previous versions of HTML defined the i element only in presentational Terms, the element has now been Given the specific semantic purpose of Representing text "offset from its surrounding content without Conveying any extra emphasis or importance, and for which the Conventional typographic Presentation is Italic text".
Which translates into:
Although earlier versions of HTML have defined element i only in terms of presentation, the element now has a specific semantic purpose of representing text "displacement of its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographical presentation is italicized text ".
Answer to the question
So if we use Icon Fonts, which are image typographies, the code will remain semantically correct, right?
Technically there is no text inside the tag, so nothing will be read from it, what exists in the particular case of using this tag to display icons is a visual representation of an image that is being applied via CSS.
Semantically wrong because the tag is not representing text.
In short: it is not right, but as there is no other way to do...
– Jean Lucas de Carvalho
Actually there is yes: how about a span? The choice of i was by saving characters, I think.
– bfavaretto
<span> will not add semantics to the page. But I agree that no semantics is better than a wrong semantics.
– Jean Lucas de Carvalho
Why not use <img> ?
– Jean Lucas de Carvalho
But we’re not talking about icons that are symbol font characters?
<img>
would not work, are not images.– bfavaretto
It’s true, my fault. I ran out of context.
– Jean Lucas de Carvalho
Semantically speaking, it is wrong use
<i></i>
and<b></b>
. Bootstrap developers have stated that they use it solely for character reduction. Ideally the closest would be to use it even<span></span>
, but no one is obliged to do so.– Emerson Rocha