CSS: DIV containing no height on float set

Set #upperDiv any of the following:

overflow: hidden;
width: 100%;

or

float: left;
width: 100%;

or create a rule using CSS pseudo-elements (IE8+ compatible) like this

#upperDiv:after {
  content: "";
  display: table;
  clear: both;
}

Best solution
Creating a reusable class rule like the following.

.group:after {
  content: "";
  display: table;
  clear: both;
}

Now you can apply it to anything that needs this same functionality. For example...

<div id='upperDiv' class="group" ... >

P.S. If you require IE 6/7 compatibility, checkout this post.


This is intentional as floats are designed for things like images in paragraphs (where multiple paragraphs can wrap around the image).

Complex Spiral has a fuller explanation as to why and Ed Elliot describes a number of approaches to making containers expand around floats. I find the overflow: hidden approach works best in most situations.