tangrs

Sorting out CSS float collapses

As an amateur web developer, one of the first problems I encountered was that floated elements with non-floated parent elements will cause the parent to collapse. This can cause headaches later on.

There are many solutions to this problem – a small list can be found in this thread on StackOverflow.

The solution I used (which I will now be using in all future projects) is to simply add this to your CSS files:

[css]
div {
overflow:hidden;
}
[/css]

After that, you’ll never need to worry about the issue again.

As an extra note, if you use Firefox to test your websites, I highly suggest you download Firebug (if you haven’t already). This has helped me find problems with my code countless times.