Why CSS Float is Sometimes Unpredictable

Submitted on July 12th, 2007 by admin
Filed under Browsers

In tweaking things around here in TipMonkies land, I have been ironing out some odd css float issues.

One of the issues I never realized is that floating a div without a set width can have unpredictable results. Just setting a width will correct most of the float issues. Firefox, not surprisingly, renders css float more intutitively; however, setting the width will insure that your pages render correctly across all browser platforms.

Now many of you may call BS and say that you float things without widths all the time. This is because float without a set width will work correctly if you are floating an image–which is its most common usage. Browsers realize that an image has a width and renders as one expects. However, a div full of text (or js script output) can be rendered many different ways. Setting the width in this case will allow rendering to be uniform and predictable.

No Responses to “Why CSS Float is Sometimes Unpredictable”

Comments are closed.

Tipmonkies Wordpress Valid XHTML Valid CSS