IE 7 not clearing floats
Hit an interesting CSS thing today. A simple “float: left.” A simple clear: both.” Firefox understands it. Even IE 6 understands it. But what the heck is IE 7 doing??? See below.
Here is how Firefox and IE 6 render that page:

Here is how IE 7 renders it:

What’s with the blue box moving around?? I was trying to avoid adding a lot of extra markup, so I made an additional class to clear the third div - thinking the next one would “top align” the following div to that one - like firefox and IE 6 do. But in IE 7, that last div is still floating left to the first few DIVs as if I never cleared that third DIV. The only way to *really* clear it is to add the extra markup of <br clear=”all” />
See this example with the extra markup (you’ll only notice the difference between this page and the previous one if you’re running IE 7)
Anyone have any thoughts as to WHY? or how the extra markup can be avoided? I mean I know a simple <br /> tag isn’t the end of the world - but I know adding those just for “layout” issues is “bad”™
(One request I’ll make: when responding - if you’re going to suggest a solution, please make sure that you’ve actually downloaded the sample and tested it there before making your suggestion. In the past I’ve had people suggesting things before they even tried it themselves to see if it’d work. Heh.) ![]()
August 6th, 2007 at 7:39 pm
I’ve been told if you go into your CSS style sheet and add the line “display: inline;” that you will will get some magical fix. It doesn’t work in IE7 I’ve noticed, still looking for the answer.
August 7th, 2007 at 2:16 pm
Actually, my IE6 on Win2000 displays it just like your IE7 snapshot…
There are differences between IE6 on Win2000 and IE6 on WinXP, I’ve noticed. Perhaps this is one of them?