Font-family with our without apostrophes?

I imported a font from google fonts, do I have to write it in CSS like this font-family: 'Lato', sans-serif; or can I just type the name without the ’ … ', like this: font-family: Lato, sans-serif;

For what I remember, the apostrophes are mandatory only if the name of the font has spaces in it.
In all the other cases, both with and without the apostrophes should be the same.

1 Like

Font names in CSS are strings, and should be quoted, but you can miss the quotes off if the font name is a valid identifier .

sans-serif and the other four generic font types (serif, monospace, cursive and fantasy) are not font names, they’re keywords: instructions to the computer to use whatever the operating system uses as default for that type. They cannot be quoted, otherwise the browser will literally look for a font called “sans-serif”, and it’s extremely unlikely that is going to be something that exists

2 Likes