Prev | Current Page 105 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

The attribute selector syntax
[class~="warning"] is rather awkward,
but thankfully there??™s a simpler and
shorter form for it: the class selector.
Here??™s a simple example that selects all
elements with a class attribute that
contains the value "warning":
Example
The following selector will match all p
elements with a class attribute that
contains the value "intro":
p.intro {
?‹® declarations
}
.warning {
?‹® declarations
}
This example also illustrates the use of an implied universal selector??”it??™s equivalent
to *.warning. Note that whitespace characters can??™t appear after the period, or
between an element type selector, or explicit universal selector, and the period. For
example, the following selector will match all p elements with a class attribute
that contains the value "warning":
The Ultimate CSS Reference 64
p.warning {
?‹® declarations
}
A simple selector may contain more than one attribute selector and/or class selector;
in such cases, the selector pattern matches elements whose attributes contain all
the specified components.


Pages:
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117