1

Possible Duplicate:
CSS: url() - are quotes needed?

You can use this:

 background-image: url("images/rock.png");

This:

 background-image: url('images/rock.png');

And this:

 background-image: url(images/rock.png);

What is the right way or is it just a preference? Does using ' ' " " make a difference? I hope my question makes sense. Thanks.

Community
  • 1
  • 1
Sarah
  • 183
  • 1
  • 1
  • 10
  • 2
    Consider looking it up in the standard, here: http://www.w3.org/TR/CSS21/syndata.html#uri – Šime Vidas Dec 23 '12 at 01:42
  • Or looking it up in SO as well http://stackoverflow.com/questions/2168855/css-url-are-quotes-needed – kittycat Dec 23 '12 at 01:43
  • There's no difference, until you use any of those characters in the URL. (Relatedly, it makes a difference in `format` on webfonts for Firefox; you need to use quotes.) – Ry- Dec 23 '12 at 01:49

2 Answers2

3

As per w3 standards there is no difference between ' and " and it is optional. Refer the standards document.

Musa
  • 96,336
  • 17
  • 118
  • 137
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
  • 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. – Roberto Alarcon Dec 23 '12 at 01:46
  • Oh. lol. I didn't know there was a standards document. – Sarah Dec 23 '12 at 01:47
  • Those "standars" are the W3C recommendations that browser vendors implement. – Roberto Alarcon Dec 23 '12 at 01:48
  • Every general technology has a standard document, which helps in the interoperability between different implementations(browsers in this case) – Arun P Johny Dec 23 '12 at 01:49
  • @Sarah [You didn't know?](http://thestevolution.files.wordpress.com/2012/06/f8446_a_jackie-chan-meme.jpg) `:P` – Šime Vidas Dec 23 '12 at 01:50
1

If you have characters i the URL that has a special meaning in CSS you need the quotation marks, for example:

background-image: url("images/some);file.jpg");

Otherwise the quotation marks are optional.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005