What quotes should be used in CSS?

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

Simple question. What quotes should be used in CSS?

Option number 1:

background: url( 'foo.png' ); 

Option number 2:

 background: url( "foo.png" ); 

Both work on "regular browsers." I just want to follow the standards.

+6
source share
3 answers

Standards say :

The format of the URI value is "url (", and then optional free space, followed by the optional single quote character () or double quote ("), followed by the URI itself, and then the optional single quote ('), or the double character quotation marks (") followed by an extra space followed by ')'. Both quotation marks must be the same.

i.e. not one, not one, not double. If you care about IE5 / Mac (which you probably don’t do these days), avoid it, otherwise use whatever is convenient for you.

+16
source

The standard is that you can use either for strings , and you can use either URLs or not for it . For the most part, there is no real difference, but if the value you are trying to quote has double quotes, then it is easier to use single quotes and vice versa.

In addition, you may prefer one or the other sequentially if you think your files are easier and easier to edit, but no one will shoot you for using the β€œwrong” one.

+2
source

I use double quotes ... This is how I saw it in books and textbooks. Just be consistent in your work.

0
source

Source: https://habr.com/ru/post/886054/


All Articles