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:

div {

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s