Forum Moderators: not2easy
I want no separation between the divs.
Can someone explain what's going on?
Help very much appreciated.
<html>
<head>
<style>
body {
background-color: black;
}
#header {
background-color: red;
margin: 0;
}
#content {
margin:0;
background-color: #ffffff;
}
#footer {
margin: 0;
background-color: red;
}
</style>
</head>
<body>
<div id="header">
<h3>Header</h3>
</div>
<div id="content">
<p>Content</p>
</div>
<div id="footer">
<h3>Footer</h3>
</div>
</body>
</html>
I thought that by giving the divs a margin of 0, they would butt up against each other. Why do the existence of a block-level element like a p or h3 tag inside the div cause the layout to "break".
Any insight appreciated.
You can read more about collapsing margins here [w3.org].