Prev | Current Page 117 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

The following declaration
block will apply to any element that matches either of the selectors in the group:
td, th {
?‹® declarations
}
We can think of the comma as a logical OR operator, but it??™s important to remember
that each selector in a group is autonomous. A common beginner??™s mistake is to
write groups like this:
#foo td, th {
?‹® declarations
}
73 Selector Reference
A beginner might think that the above declaration block will be applied to all td
and th elements that are descendants of the element with an ID of "foo". However,
the selector group above is actually equivalent to this:
#foo td {
?‹® declarations
}
th {
?‹® declarations
}
To achieve the true goal, write the selector group as follows:
#foo td, #foo th {
?‹® declarations
}
Selector Reference
No Trailing Comma Needed
Don??™t leave a comma after the last selector in the group!
Combinators
A selector can contain more than one simple selector. Between the simple selectors,
we must include a combinator??”something that explains the relationship between
the selectors.


Pages:
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129