Which type of quotes we should use in css background url ("....")? Single, double or no quote needed?

Jitendra Vyas picture Jitendra Vyas · Jan 9, 2010 · Viewed 10.7k times · Source

this

background:url(http://url);

this

background:url("http://url");

or this

background:url('http://url');

Answer

Dexter picture Dexter · Jan 9, 2010

The URL bits of all three of your examples are valid CSS, according to the CSS specification.

Note that the spec identifies some characters in a URL which will need to be escaped with a backslash if present in an unquoted URI, such as parentheses, commas, white space characters, single quotes (') and double quotes ("). For this reason, you might find it better to use single or double quotes around your URLs.

Note that you need to write your full CSS property in the format:

background: url( http://example.com );