I'm encountering an issue with my HTML/CSS code here:
CSS
* { padding: 0; margin: 0; border: none; outline: none; }
#container {
margin: 10px auto 10px auto;
width: 960px;
background-color: #dddddd;
border: solid 1px black;
}
#container2 {
margin-left: 200px;
margin-top: 400px;
background-color: yellow;
}
HTML
<body>
<div id="container">
<div id="container2">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</body>
Everything appears as expected on the page, with the lower yellow div positioned 400px below the top border of the gray outer div.
However, when I remove the line border: solid 1px black;
from the #container
style definition, the gray outer div starts from the same top position as the inner yellow div.
This unexpected behavior occurs in Firefox 3.x and Chrome.
Can someone shed light on why this is happening? In theory, removing the border style should not impact the layout at all.