Child's top margin and parent's background

Giganews Newsgroups
Subject: Child's top margin and parent's background
Posted by:  Thomas Mlynarczyk (blue_elephant…@hotmail.com)
Date: Wed, 15 Dec 2004

Hello,

The following gives different results in IE and "Non-IE" browsers:

<div style="background-color: green; width: 200px">
  <div style="margin-top: 20px; background-color: red">
    Hello
  </div>
</div>

While IE shows a visible green top margin of 20px, Mozilla and other
browsers start the parent element's background color only at the height of
the inner div, thus showing no green at all. Is there a way to achieve the
same behaviour (one way or the other) in all browsers?

Greetings,
Thomas

Replies