IE7-/Win: Problems with float + clear on the same element

1.

b1. float: left
blah
b2. float: left + clear: both

2.

b1. float: right
blah
b2. float: right + clear: both

3.

b1. float: left
blah
b2. float: right + clear: both

4.

b1. float: left
blah
b2. clear: both

5.

b1. float: right
blah
b2. float: left + clear: both

6.

b1. float: right
blah
b2. clear: both

7a.

b1. float: left
b2. float: right
blah
blah
b3. float: left + clear: both

7b.

b1. float: left
blah
blah
b2. float: right
b3. float: left + clear: both

8a.

b1. float: left
b2. float: right
blah
blah
b3. float: right + clear: both

8b.

b1. float: left
blah
blah
b2. float: right
b3. float: right + clear: both

9a.

b1. float: left
b2. float: right
blah
blah
b3. clear: both

9b.

b1. float: left
blah
blah
b2. float: right
b3. clear: both

10a.

b1. float: right
b2. float: left
blah
blah
b3. float: left + clear: both

10b.

b1. float: right
blah
blah
b2. float: left
b3. float: left + clear: both

11a.

b1. float: right
b2. float: left
blah
blah
b3. float: right + clear: both

11b.

b1. float: right
blah
blah
b2. float: left
b3. float: right + clear: both

12a.

b1. float: right
b2. float: left
blah
blah
b3. clear: both

12b.

b1. float: right
blah
blah
b2. float: left
b3. clear: both

13.

b1. float: left
blah
b2. float: right + clear: left

14.

b1. float: left
blah
b2. float: right + clear: right

15.

b1. float: right
blah
b2. float: left + clear: right

16.

b1. float: right
blah
b2. float: left + clear: left

In all the above test cases there are boxes in a gray container, called b1, b2, b3 according to their source order. All the boxes (and the container) have hasLayout (MS.) Most of the boxes are floated as indicated in the box itself (the green and blue ones); some have clear set (the blue and red ones.) The combination float+clear triggers several anomalies in IE7-/Win. In short:

  1. A float having the clear property (value both) only clears preceding floats of its same direction (left/right.) This fact is responsible for the wrong behaviour in the following cases:

    The clear property works correctly on not floated elements. The following cases correspond to the six wrong ones previously mentioned, but are correctly rendered since clear is applied to a not-floated element:

  2. If the window is narrowed so that the gray wrappers are not wide enough to contain side by side a (green) float box and a (blue) float+clear one, then the following happens in the above mentioned cases of missing clear effect:

    A further strange and wrong behaviour shows up in cases 8a and 11b: A right float with clear: both preceded by a left float doesn't go enough to the left. The right side of the preceding left float acts as a barrier, even if the left and right floats are vertically separated.

    Cases 13-16 show that any clear (left, right or both) on a float following an opposite side float not only misses to clear the first one when required, but also makes the second float unable to drop below the first one when lack of horizontal space required so.

Other problems in IE7-/Win caused by float and clear on the same element.

CSS tests home