问题原文
原帖链接 · Amirreza Nasiri · CC BY-SA 3.0
For making a user friendly website, I have to use some of Font Awesome fonts in <h> elements like this:
<h2>
<i style="color: rgb(102, 149, 45); vertical-align: inherit;" class="fa fa-gear"></i>
Performance
</h2>
In fact, this is a review article. Is it OK to put these fonts (or <i> elements) in the inner HTML of header elements like <h1>, <h2>, <h3>, etc.?
Please provide your source or some documentation, too, because it's really important for me; I don't want to make any mistakes about this topic.
已采纳解答
原帖链接 · Martijn · CC BY-SA 3.0
I would say it wouldn't harm much, nor will it add anything. I prefer to keep my header tags clean and wouldn't add the i. The inline styling would be a bigger problem, which isn't really an big issue.
Instead of doing this, you can add the gear icon to the H2 directly:
h2.Geared:before{
display: inline-block;
color: rgb(102, 149, 45);
font-family: "FontAwesome";
content: "\f013"; /*The actual character FontAwesome uses */
}
<h2 class="Geared">This text will have the gear</h2>
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
