Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the First Selection in a Font Family Always Quoted?

Tags:

css

In almost all CSS font-family declarations I've seen, the first font selection is quoted.

Example:

{
font-family:"Times New Roman", Georgia, Serif;
}

The first 2 selections are both specific fonts, while the third selection 'Serif' is a generic font family. Why is Times New Roman in quotations, but not Georgia? This discussion talks about how quotations are not always needed, but it doesn't explain why only the first selected font would be in quotations.

like image 241
Lloyd Banks Avatar asked Dec 21 '12 16:12

Lloyd Banks


People also ask

Do you need quotes for font family?

Quotes are recommended in the spec with "font family names that contain white space, digits, or punctuation characters other than hyphens". Quotes are required around font-family names when they are not valid CSS identifiers.

Why is the name of one of the font put in quotes?

Why is the name of one of the fonts put in quotes? . it consists of two words or it shows a font family or to support "fallback" or it is a rarely used font...

What is the purpose of having more than 1 value for font family property?

Not all browsers support all the fonts. So, giving multiple font families select the font that is supported by the browser, starting from the first font. If first font is supported then it is used, otherwise it checks if next font is supported and so on.

What are the two 2 types of font family names?

There are two types of font family names: family-name - The name of a font-family, like "times", "courier", "arial", etc. generic-family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace".


2 Answers

It's because Times New Roman has spaces, any other that has should be quoted as well.

like image 92
Otávio Décio Avatar answered Oct 01 '22 22:10

Otávio Décio


This is interesting, I figure it has to do with spacing in the name.

The official spec says this:

To avoid mistakes in escaping, it is recommended to quote font family names that contain white space, digits, or punctuation characters other than hyphens:

So, it probably has nothing to do with being the first one :-)

Reference: http://www.w3.org/TR/CSS21/fonts.html#font-family-prop

like image 29
Bartek Avatar answered Oct 01 '22 22:10

Bartek