Prev | Current Page 112 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

php">.
Attribute Selectors for IDs
Note that [id="foo"] isn??™t equivalent to #foo. Although both selectors would match
the same element in HTML, there??™s a significant difference between their levels of
specificity (p. 126).
We can use the |= operator to cause an attribute selector to match elements which
have an attribute containing a hyphenated list of words that begin with a specific
value:
[hreflang|="en"] {
?‹® declarations
}
This example selector matches any element that has an hreflang attribute containing
a value of "en", whether or not that value is followed by a hyphen and more
characters. In other words, it matches hreflang attribute values of "en", "en-US",
"en-GB", and so on. This selector syntax was intended to allow language subcode
matches.4
Hyphen or No Hyphen?
All supporting browsers allow a hyphen to appear in the value in a selector like
[hreflang|="en"]. It??™s unclear whether or not this is illegal, because the CSS
specification doesn??™t contains any guidelines to help us deal with this situation.


Pages:
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124