I remember hearing a long time ago that it was considered “best practice” to wrap quotes around font names that contain multiple words in the CSS font-family property, like this:
font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
For the heck of it, I tried removing the quotes from "Arial Narrow" and Safari and Firefox don’t have any problem rendering it.
So, is there any logic to this rule of thumb, or is it just a myth? Was it an issue with older browsers that no longer applies to the current versions? I’ve been doing this for so long that I never stopped to think if it was actually necessary.
The CSS 2.1 spec tells us that:
It goes on to say:
So yes, there is a difference, but one that’s unlikely to cause any problems. Personally, I have always quoted font names when they contain spaces. In a few (presumably very rare) cases, the quotes are absolutely required:
Also note that punctuation such as / or ! within an identifier may also need to be quoted or escaped.