Within the body of HTML 5 and with a specified doctype , I have the following code:
<div style="width:100%; background-color: #cccccc;">
<div style="margin-top:20px; width:100px; background-color: #aa0000;">Sub</div>
Main
</div>
When viewing in firefox, the outer div is rendered with a margin of 20px from the top of the page. However, I only want the sub div to have a 20px margin from the outer div. This can be achieved by placing text above the sub div as shown below:
<div style="width:100%; background-color: #cccccc;">
Main
<div style="margin-top:20px; width:100px; background-color: #aa0000;">Sub</div>
Main
</div>
For reference: http://jsfiddle.net/F3kXw/2/
This issue is puzzling to me as it's something I haven't encountered before.