为什么字体名称需要引号? [英] Why would font names need quotes?

查看:160
本文介绍了为什么字体名称需要引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,如果字体包含空格,则需要为字体使用双引号或单引号,例如:

As far as I know, one needs to use double or single quotes for fonts if they contain spaces, like:

font-family: "Times New Roman", Times; 
font-family: 'Times New Roman', Times;

但是在Google Fonts( http://www.google.com/webfont ),我还看到

But on Google Fonts (http://www.google.com/webfont), I also see

font-family: 'Margarine', cursive;

有些甚至使用它:

font-family: 'Margarine', 'Helvetica', arial;

我发现这很奇怪,如下所示:

I find this weird, as the following works as well:

font-family: Arial, Helvetica, sans-serif;
font-family: Cambria, serif;

那么CSS中字体名称引号的正确用法是什么?

So what is the correct usage of quotes around font names in CSS?

推荐答案

您可以随时将特定字体系列名称用双引号或单引号括起来,因此 Arial Arial'Arial'是等效的。只有CSS定义的通用字体系列名称(例如 sans-serif )必须没有引号。

You can always put a specific font family name in quotes, double or single, so Arial, "Arial", and 'Arial' are equivalent. Only the CSS-defined generic font family names like sans-serif must be written without quotes.

信念,由空格分隔的名称组成的字体名称,例如 Times New Roman 不需要引用。但是,规格 建议引用字体包含空格,数字或除连字符

Contrary to popular belief, a font name consisting of space-separated names such as Times New Roman need not be quoted. However, the spec recommends "to quote font family names that contain white space, digits, or punctuation characters other than hyphens"

这篇关于为什么字体名称需要引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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