什么时候CSS字体家族值使用引号? [英] When should CSS font-family value use quotes?
问题描述
什么时候CSS'font-family'的值有引号括起来?
我已经看到 font-family:arial
和 font-family: Arial字体
。
作为一个具体的例子,我用这种方式声明一个字体:
@ font-face {
font-family:'entypo';
font-style:normal;
font-weight:400;
src:url('/ css / fonts / entypo.woff')格式('woff');
$ b $ p
$ b 有一个元素使用这个font-family的正确的CSS是什么? / code>。
Arial
不需要引号,但有些人使用引号,如Arial
要更一致。这是简单的个人喜好。
在Justin的下面的评论中看到: font-family:times new roman;
( jsFiddle )。
你可以打电话给你新的 @ font-face
使用 font-family:'entypo';
(链接)
When should the value for CSS 'font-family' have quotes around it?
I've seen both font-family: arial
and font-family: "arial"
.
As a specific example, I declare a font this way:
@font-face {
font-family: 'entypo';
font-style: normal;
font-weight: 400;
src: url('/css/fonts/entypo.woff') format('woff');
}
What would be the correct CSS to have an element use this font-family?
解决方案 You only need quotes when the font itself has a space such as "Times New Roman"
.
Arial
does not need quotes, but some people use quotes such as "Arial"
to be more consistent. It is simply personal preference.
Seen in Justin's below comment: font-family: times new roman;
works without spaces (jsFiddle).
You can call your new @font-face
using font-family: 'entypo';
as you would normally expect. (link)
这篇关于什么时候CSS字体家族值使用引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!