views:

40

answers:

3

e.g.:

a[href="val"]

Does "val" need to have quotes around it? Single or double are acceptable? What about for integers?

+1  A: 

No, they don't have to have quotes, tough in order to avoid ambiguities many people do use quotes, which are needed if the value contains whitespace.

Either single or double quotes are fine, and integers will be treated the same way (css does not have a distinction between strings and integers).

See the examples in the spec.

Oded
+1  A: 

They do not need to be quoted.

There is also no distinction between strings/doubles/integers. CSS isn't Turing-complete, let alone typed.

Matt Ball
+5  A: 

According to the examples in the CSS 2.1 specs, quotes are optional.

In the following example, the selector matches all SPAN elements whose "class" attribute has exactly the value "example":

span[class=example] { color: blue; }

Here, the selector matches all SPAN elements whose "hello" attribute has exactly the value "Cleveland" and whose "goodbye" attribute has exactly the value "Columbus":

span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }

Numbers are treated like strings, i.e. they can be quoted, but they don't have to.

Pekka
Ah.. was reading the css3 spec, all the examples I saw used quotes.
Mark