Thursday, October 8th, 2009 | Tips, Web Dev

float: left; and float: right;

I make websites for a living. I also make websites for fun, either way it’s what I do. When I’m making a 2-column layout, I always float the first left, and the second right. Why? Because I can avoid using too much margin and breaking the site in IE6, due to the notorious float margins bug. I don’t like building a website specifically for IE6, but since every other browser doesn’t mind which way you float an element. It’s always been easier for me to do it like this:

<div class="content" style="float:left;>
    content goes inside
</div>
<div class="sidebar" style="float:right;">
    content goes inside here too
</div>

And there you go! Nothing special here. just a very quick tip.

Filed Under: Tips, Web Dev

No Comments yet

Leave a Comment