[css-d] Adjacent sibling selectors not taking - solved!
Never mind, the moment I had written it down the solution hit me: what I want is the first child selector! Cheers Martin __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] Adjacent sibling selectors not taking
At 1:21 +1000 10.4.2008, Alan Gresley wrote: >But even better. > > >h1:first-child, h2:first-child, h3:first-child { >margin-top: 0em; >} Excellent! Thank you so much! It's been a great relief to be able to use these exciting selectors now that IE7 finally supports them. Cheers Martin __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] Adjacent sibling selectors not taking
Martin Sammtleben wrote: > Hi everyone, > > I use the general selector to zero my paddings and margins. I then > add in some defaults for common elements: > > p, h1, h2, h3 { > margin-top: 0.5em; > margin-bottom: 0.5em; > } > > ...and then use adjacent sibling sel. to refine them, which works well: > > p+h1, p+h2, p+h3 { > margin-top: 1.5em; > } > > > Now I have a sidebar that I want to remove the default top margins of > any heading elements on the very first line, so I hoped a rule like > this would do the trick, but to no avail: > > div#sidebar+h1, div#sidebar+h2, div#sidebar+h3 { > margin-top: 0em; > } > > Why does the rule not work? Am I misunderstanding how these are > supposed to work? Brother and Sister are siblings. This selectors div#sidebar+h1 selects the h1 following div#sidebar (does one exist?). It's a child selector > you need. > (Changing it to a descendant selector like div#sidebar h1, etc. > shows the desired effect, but sadly on other h selectors further > down, too.) > > Any help is very much appreciated! > > > CheersMartin But even better. h1:first-child, h2:first-child, h3:first-child { margin-top: 0em; } Work in IE7, IE8 and other good browsers. Alan http://css-class.com/ __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
[css-d] Adjacent sibling selectors not taking
Hi everyone, I use the general selector to zero my paddings and margins. I then add in some defaults for common elements: p, h1, h2, h3 { margin-top: 0.5em; margin-bottom: 0.5em; } ...and then use adjacent sibling sel. to refine them, which works well: p+h1, p+h2, p+h3 { margin-top: 1.5em; } Now I have a sidebar that I want to remove the default top margins of any heading elements on the very first line, so I hoped a rule like this would do the trick, but to no avail: div#sidebar+h1, div#sidebar+h2, div#sidebar+h3 { margin-top: 0em; } Why does the rule not work? Am I misunderstanding how these are supposed to work? (Changing it to a descendant selector like div#sidebar h1, etc. shows the desired effect, but sadly on other h selectors further down, too.) Any help is very much appreciated! Cheers Martin __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/