CSS Master

(Primo) #1
Figure 1.6. Using the adjacent sibling combinator to adjust the bottom margin for our fieldset elements

More Uses of the Adjacent Sibling Selector
HeydonPickeringexploresmorecleverusesoftheadjacentsiblingselectorinhis
article“AxiomaticCSSandLobotomizedOwls.”^4

Whatifwewanttostyleasiblingelementthatisn’tadjacenttoanother,aswithour
Number of Ticketsfield?Inthiscase,wecanusethegeneralsiblingcombinator.

The General Sibling Combinator
Withthegeneralsiblingcombinator―a tilde―we can select elements that share
the same parent without considering whether they’re adjacent. Given the pattern
A~B,thisselectormatchesallBelementsthatareprecededbyanAelement,
whetherornotthey’readjacent.

(^4) http://alistapart.com/article/axiomatic-css-and-lobotomized-owls
10 CSS Master

Free download pdf