<html>
<head>
<style type="text/css">
div
{
background-color:#ccc;
}
</style>
</head>
<body>
<div>
<div style="float: left;">This is a text inside a div element.</div>
<div style="float: right;">We are still in the div element.</div>
</div>
</body>
</html>
Why isnt the background color showing up in between those 2 divs?

When you float elements you should provide the width of the floated elements. Otherwise you may encounter unexpected behaviors accross different browsers.
Check this tutorial, there is good info on floating in css. [link is dead]
Basically, if you provide an
overflow:hidden;to the container div and provide width to the floated elements, your problem will be solved.Similarly, you can add another div wherever you want to normalize the flow ike this:
Both will work 🙂
EDIT
Another method which I use frequently in these days is to float the first element and set a
margin-leftto the following element. For instance:The advantage of this method is that the following element (the second div in this case) does not need a fixed width. Plus, you may skip the third div (
clear: both;). It’s optional. I just add it in case that the floated div is longer in height than the second div since if you don’t add it the parent div will always get the height of the second div.