I want the outer div
, which is black to wrap its div
s floating within it. I dont want to use style=\'height: 200px
in the div
First of all you don't use width=300px
that's an attribute setting for the tag not CSS, use width: 300px;
instead.
I would suggest applying the clearfix
technique on the #outerdiv
. Clearfix is a general solution to clear 2 floating divs so the parent div will expand to accommodate the 2 floating divs.
<div id='outerdiv' class='clearfix' style='width:600px; background-color: black;'>
<div style='width:300px; float: left;'>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</div>
<div style='width:300px; float: left;'>
<p>zzzzzzzzzzzzzzzzzzzzzzzzzzzzz</p>
</div>
</div>
Here is an example of your situation and what Clearfix does to resolve it.