My application has 1 parent box and 2 child boxes (divs). At the moment, the child boxes appear below each other
<div class="a">
<div class="b">This is b</div>
<div class="c">This is c</div>
</div>
.a{border:solid;width:300px;}
.b{border:solid;width:100px;color:red;}
.c{border:solid;width:100px;color:green;}
Now, I want my 2 boxes (b and c) to be beside each other. I add a float left to both b and c
.a{border:solid;width:300px;}
.b{border:solid;width:100px;color:red;float:left;}
.c{border:solid;width:100px;color:green;float:left;}
As you can see, this has moved the children into the correct place, but the parent isn't framing them any more.
To fix it, I have to add a float left to the parent (wrapper) class but this then means the parent class if now floated, which surely must mean if this has a parent than that too has to float left, as it will all the way up the tree until the body tag?
My question is, why does the outer div (a) behave in this manner when it is not floated? Can I assume that because the children are floating, then the children are treated as if they're not there which is why the outer div's border doesn't encapsulate them?