Replicating float avoidance in standard compliant web browsers

In IE7- there is a nice way of “clearing” floats, as when there is not enough room for a block it drops below the float and the vertical margins just work right. The following code is a working example showing this behavior in IE7-

<!DOCTYPE html>
<meta charset="iso-8859-1">
h1, h2, p {margin:20px;}
div.image {margin:0 20px;float:left;display:inline;height:50px;background-color:red;}
div#wrapper {width:760px;}
h2 {width:720px;}
<div id=wrapper>
<h2>Section 1</h2>
<div class=image>image</div>
<p>Some text.</p>
<h2>Section 2</h2>
<p>Some more text.</p>

Using h2 {clear:both;} only gets it half right, because h2 gains uncollapsible margins.

Is there a way of replicating this good behavior of IE7- in standard compliant browsers only changing the CSS code?

BTW, do not cheat with h2:first-child to circumvent classistis on the first h2, as it is intended to be generic. :smiley:

Giving the h2 overflow:auto will drop it below the floated div. The top margin of the h2 will not be observed but you could add a bottom margin to the floated div.

Note that applying display:inline to a floated element is superfluous. float = block.