Please help me to understand why the image–div of the following code flows out of the box–div.
<body>
<div id="box" style="border: 2px solid green;">
<div id="image" style="height: 200px; width: 200px; background: red; float: left;"></div>
<div id="text" style="background: yellow;">This is some text</div>
</div>
</body>
In other words, I expected the green border to fully enclose both inner divs and not only the yellow one.
When a children its floating the parent doesn’t wrap it. You can use two solutions for this:
Or
You can also use
display:inline-blockfor the#boxbut that doesn’t work on IE6