At first this question seem simple, from all the real life examples I have seen, is used for displaying icons. For example the twitter bootstrap icons.
However, when I search tag in google, the w3c school says is for italic text.
I am confused, if is used for italic text, why is everyone using it for icons? What is the proper use of this tag??
The ID attribute uniquely identifies elements on a page. It does not make sense to duplicate an ID.
The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.
As HTML and CSS are designed to be very fault tolerant, most browsers will in fact apply the specified styles to all elements given the same id. However, this is considered bad practice as it defies the W3C spec. Applying the same id to multiple elements is invalid HTML and should be avoided.
Classes are not uniqueYou can use the same class on multiple elements. You can use multiple classes on the same element.
It should be used to make text styled italic. Most semantic uses for italic text are <em>
, as it is supported by screen-readers for emphasis.
<i>
and <b>
are slowly going out of fashion in favour of using CSS to style text, and preserving <em>
and <strong>
for accessibility reasons.
I guess that it was selected for icons since it is the closest element and makes alphabetic sense (i.e. i = icon).
Because HTML has become perverted over the ages.
Official "proper use" in HTML 4.01 is for italic text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With