使用< i>的好处是什么?在元素之前而不是在< span>中包装元素? [英] What are the advantages of using <i> before an element instead of wrapping the element in <span>?

查看:179
本文介绍了使用< i>的好处是什么?在元素之前而不是在< span>中包装元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:
< I>标记图标?


我在 FontAwesome 为了使用图标字体,他们使用了一个空的< i> code>,如下所示:

 < a class =btnhref =#> 
< i class =icon-refresh>< / i>刷新
< / a>

而不是用< span> 像这样:

 < a class =btnhref =#> 
< span class =icon-refresh>刷新< / span>
< / a>

我也看到其他一些网站也采用类似的技术。 AFAIK,这两种技术都是在之前使用CSS伪元素:所以我想知道他们为什么要用< i> 而不是用< span>



来包装它有没有任何优势使用空的< I> ?它是语义吗?

解决方案

我能想到的唯一优点就是< i> 写的时间较短(而不是通过电报发送,因此gzip不关心它,如果是i或跨度为20个字母的类),它与其他标记不同。它就像自制的图标标签一样。

但是在< i> 无论如何。


i元素表示一段文字的交替的声音或情绪,
或以其他方式偏离正常散文例如b $ b分类学名称,技术术语,来自另一
语言的习语,思想,船名或某些其他散文,其典型的
印刷呈现以斜体表示。 p>

http://www.w3.org/International/questions/qa-b-and-i-tags/



那它是语义的吗?不,但没有人关心,没有什么大不了的。

Possible Duplicate:
<I> tag for icons?

I've seen in FontAwesome that to use their icon fonts, they are employing an empty <i>, something like this:

<a class="btn" href="#">
   <i class="icon-refresh"></i> Refresh
</a>

instead of wrapping it with <span> like this:

<a class="btn" href="#">
   <span class="icon-refresh">Refresh</span>
</a>

I've seen some other websites employ similar technique too. AFAIK, both technique utilizes the CSS pseudo-element :before, so I wonder why do they use <i> instead of wrapping it with <span>?

Are there any advantages on using an empty <i>? And is it semantic?

解决方案

The only advantage I can think of is just that <i> is shorter to write (and not to send over the wire, cause gzip doesn't care much if its i or span with 20-letters class) and it's distinctive from other markup. It is like self-made tag for icons.

But there are no other semantic value in <i> whatsoever.

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/

So is it semantic? No. But no one cares, no big deal.

这篇关于使用&lt; i&gt;的好处是什么?在元素之前而不是在&lt; span&gt;中包装元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆