Possible Duplicate:
<I> tag for icons?
我在 FontAwesome 中看到过为了使用他们的图标字体,他们使用了一个空的 <i>
,像这样:
<a class="btn" href="#">
<i class="icon-refresh"></i> Refresh
</a>
而不是用 <span>
包装它像这样:
<a class="btn" href="#">
<span class="icon-refresh">Refresh</span>
</a>
我看到其他一些网站也采用了类似的技术。据我所知,这两种技术都利用了 CSS 伪元素 :before
,所以我想知道他们为什么使用 <i>
而不是用 <span>
包装它?
使用空的 <i>
有什么好处吗? ?它是语义化的吗?
我能想到的唯一优点就是<i>
写起来更短(而不是通过网络发送,因为 gzip 不太关心它的 i 或 span 是否为 20 个字母的类)并且它与其他标记不同。它就像图标的自制标签。
但是<i>
中没有其他语义值无论如何。
The i element represents a span of text in an alternate voice or mood,
or otherwise offset from the normal prose, such as a taxonomic
designation, a technical term, an idiomatic phrase from another
language, a thought, a ship name, or some other prose whose typical
typographic presentation is italicized.
http://www.w3.org/International/questions/qa-b-and-i-tags/
那么它是语义化的吗?没有。但是没人在乎,没什么大不了的。