This code displays a pink box:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css">
html, body { margin: 0; }
.frame { width:50%; height: 50%; position: absolute; }
.left { left: 0%; }
.right { left: 50%; }
.top { top: 0%; }
.bottom { top: 50%; }
</style>
</head>
<body>
<div class="frame top left" style="background-color:gr
een">
<div style="height:100%;width:1
00%;backgr
ound-color
:pink">
</div>
</div>
</body>
</html>
However when I add a <p> element inside the pink box, Firefox and Opera displays a green bar but IE doesnt. Opera/Firefox also displays the pink box, still the same height but now ending further down the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css">
html, body { margin: 0; }
.frame { width:50%; height: 50%; position: absolute; }
.left { left: 0%; }
.right { left: 50%; }
.top { top: 0%; }
.bottom { top: 50%; }
</style>
</head>
<body>
<div class="frame top left" style="background-color:gr
een">
<div style="height:100%;width:1
00%;backgr
ound-color
:pink">
<p>hello</p>
</div>
</div>
</body>
</html>
Just trying to understand the logic of whats going on. I can see that IE is collapsing the top margin of the initial p element, and firefox/opera isnt, but why isnt that margin applied to the inner div (the pink one) pushing the p down a line inside the pink div? The margin has pushed the pink div down a line, which I didnt expect.
Thanks
What you are seeing is the unstyled "default" behavior differences between these browsers. If you style the you will gain complete control.
Best, ~Ray