leo
leo

Reputation: 8520

Difference between "font-family" and font-family?

I just discovered that my Chrome will treat font-family: "sans-serif" and font-family: sans-serif differently (it will choose different fonts). Can anyone explain how this works? I can't find any clues in the specs. [edit: ...as I obviously didn't read them very carefully.]

Upvotes: 3

Views: 1762

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172418

From the same specs:

If a sequence of identifiers is given as a font family name, the computed value is the name converted to a string by joining all the identifiers in the sequence by single spaces.

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 when you are writing "san-serif" then it is a specific font and is considered as a string whereas the latter is considered as generic.

Upvotes: 7

Related Questions