Clearning a float with CSS

If you are using floats in your layout (which you most definitely are) then you probably have run into problems. Just the other day I was using floats to create a simple two column layout and I found that it worked in Chrome but not in Firefox. Once I used the clearfix class the layout worked in both browsers.

I get a lot of emails with students having problems because CSS’ ‘clear:both’ is not doing what they want it to do. Save yourself lots of headache and use .clearfix. It should be noted that this is baked into html5boilerplate (as is a whole bunch of other cool stuff).

Leave a Reply

Your email address will not be published. Required fields are marked *