Whenever I try to position a div inside another div using float, I encounter problems.
<div id="main">
<div id="anotherDiv">
<h1>Test</h1>
</div>
</div>
Here is the corresponding style sheet:
#main{ background-color:red; padding:20px; }
#anotherDiv{ background-color:blue; }
This is how my page looks like without using float property:
And this is what happens when I add the following style:
#anotherDiv{ float:left; }
However, I would like to achieve something like this:
What should I do in this case?