Which of the following should I use in my stylesheets?
/* Example #1: */ background-image: url(image.png);
/* Example #2: */ background-image: url(\"image.pn
Better use quotes because it's recommended by the newest standard and there're fewer edge cases.
According to the newest Editor's Draft of CSS Values and Modules Level 3 (18 December 2015)
A URL is a pointer to a resource and is a functional notation denoted by
. The syntax of ais:
= url( * )
The unquoted version is only supported for legacy reasons and needs special parsing rules (for escape sequences, etc.), thus being cumbersome and not supporting url-modifiers.
That means, the url(...) syntax is supposed to be a functional notation, which takes a string and a url-modifier as parameters. Use the quote notation (which produces a string token) would be more standard-compliant and introduce less complexity.
@SimonMourier's comment in the top answer is wrong, because he looked for the wrong spec. The url-token type is only introduced for the legacy special parsing rules, so that's why it does not have anything to do with quotes.