G. Sørtun skrev: > Benct Philip Jonsson wrote: >> So that's the margins of the h1 and the p interfering? Outside the >> boxes of the divs which contain them? I *really* don't understand >> how margins are calculated! > > You're encountering "collapsing margins"... > > <http://www.w3.org/TR/CSS21/box.html#collapsing-margins> > > ...and in your case it's easier to think about them as "escaping > vertical margins". The vertical margins on elements do indeed escape > containers, but will stop escaping inside the first containing-box that > has vertical paddings set on it - one of the W3C-standardized "contain > vertical margins" solutions available to us. Which "contain vertical > margins" solution that works best will always depend on the actual case, > but vertical paddings on the innermost containing-box will always do the > job.
Will setting any small amount of padding on the innermost containing box do the trick, like 1px or even 0px as opposed to not declaring any padding at all? /BP > Keep the above W3C link handy, study what it says, but don't worry too > much about not understanding exactly how "collapsing margins" works in > its minutest details. Those who write standards and build browsers have > had their fair share of failures in writing and programming in and out > around those collapsing margins" over the years, and you may still run > into some unclear and inconsistent cases in both camps. > > regards > Georg > ______________________________________________________________________ css-discuss [cs...@lists.css-discuss.org] 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/