Is quoting the value of url() really necessary?

The W3C says quotes are optional, all three of your ways are legal.

Opening and closing quote just need to be the same character.

If you have special characters in your URL, you should use quotes or escape the characters (see below).

Syntax and basic data types

The format of a URI value is ‘url(‘ followed by optional white space followed by an optional single quote (‘) or double quote (“) character followed by the URI itself, followed by an optional single quote (‘) or double quote (“) character followed by optional white space followed by ‘)’. The two quote characters must be the same.

Escaping special characters:

Some characters appearing in an unquoted URI, such as parentheses, white space characters, single quotes (‘) and double quotes (“), must be escaped with a backslash so that the resulting URI value is a URI token: ‘\(‘, ‘\)’.

Leave a Comment