|
Hey Guys,
In my attempt to fully understand css something has always thrown me off. Why is it that the vertical margins of any <p>, <h1> etc element don't expand the <div> unless it has a border?
For example:
<div style="background-color:blue; margin:0px; border:1px solid black">
<div style="background-color:red; margin: 0px; ">
<h1 style="margin:50px;">Here we go</h1>
</div>
</div>
In this example the h1 margin won't push the "red" <div> up or down by 50px. Instead it will push the "blue" <div> surrounding it, up by 50px because it has the border. What is the reasoning behind this? And is there a way to make it so the "red" <div> would expand up and down without putting a border on it?
Thanks
|