6

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.

Community
  • 1
  • 1
Lloyd Banks
  • 35,740
  • 58
  • 156
  • 248

3 Answers3

12

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

Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
  • 1
    Definitely...not "probably". `{ font-family: Arial, sans-serif, "Times New Roman" }` is not only just as valid, it defines order of preference too. ie: I want Arial, if they have it. If not, I want sans-serif. etc. – Dawson Dec 21 '12 at 17:01
8

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

Bartek
  • 15,269
  • 2
  • 58
  • 65
0

There is no reason why the first font name should be quoted, but presumably the declarations that you have been reading have often mentioned a name consisting of several words as the first name. Many fonts have such names, and probably other font names that people list down have been copied from some list of common fonts with simple (one-word) names.

If you view the CSS code for SO pages, you will see font-family: Arial, Helvetica, sans-serif;. No quotes. No quotes are actually needed around Times New Roman either, but people tend to take warnings seriously enough and quote such names.

So unless you can provide evidence of declarations where several multi-word font names are listed and only the first one is quoted, this is just a symptom of simplistic thinking: people may consider the choice of primary font, possibly selecting a multi-word name, and then they write a more or less random list of other fonts, with simple names.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390