margin-collapse-164.xht (1425B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: Margins on cleared blocks that contain floats</title> 5 <link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch"/> 6 <link rel="alternate" href="http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/064.html" type="text/html"/> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins"/> 8 9 <style type="text/css"> 10 .outer { margin: 1em; background: red; height: 4.5em; } 11 .border { border: solid; width: 10em; } 12 .box { margin: 0; background: yellow; } 13 .float { margin: 0; width: 5em; height: 1.5em; background: orange; float: right; } 14 .clear { margin-top: 3em; height: 1.5em; background: aqua; clear: both; } 15 .control { border: solid; width: 10em; background: yellow; margin: 1em; } 16 .control .a { margin: 0 0 0 auto; width: 5em; height: 1.5em; background: orange; } 17 .control .b { margin-top: 1.5em; height: 1.5em; background: aqua; } 18 </style> 19 </head> 20 <body> 21 <p>The following two boxes should be identical, with no red present.</p> 22 <div class="outer border"> 23 <div class="box"> 24 <div class="float">TEST</div> 25 <div class="clear">TEST</div> 26 </div> 27 </div> 28 <div class="control"> 29 <div class="a">TEST</div> 30 <div class="b">TEST</div> 31 </div> 32 33 </body> 34 </html>