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!
>
>
> Cheers Martin
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/