Do I need to specify values ​​in CSS attribute selector values?

eg:.

a[href="val"]

Do I need to have a β€œshaft” quotes? Are single or double acceptable? What about integers?

+3
source share
4 answers

TL; DR: Quotes required if the value does not meet the specification for CSS2.1

The CSS specification may say that they are optional, but the real world presents a different story. When matching with the href attribute you will need to use quotation marks (single or double work in my very limited testing - latest versions of FF, IE, Chrome.)

, css spec, @Pekka, href .

- --, , - ~ = , . "a >

, ( ). CSS2 , , CSS3 CSS21:

http://www.w3.org/TR/css3-selectors/

CSS. [CSS21] .

:

http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

CSS ( , ) [a-zA-Z0-9] ISO 10646 U + 00A0 , (-) (_); , , . ISO 10646 (. ). , "B & W?" "B\& W \?" "B\26 W\3F".

, , '~ =' , href. '* =' . , "domain", href= 'www.domain.com'. , .

+3

CSS 2.1 .

SPAN, "class" "example":

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

SPAN, "hello" "Cleveland" "" "Columbus":

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

, .. , .

+3

, , , , , , .

, (css ).

. .

+1

.

There is also no difference between strings / doubles / integers. CSS is not Turing-complete , not to mention input.

-1
source

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


All Articles