margin-collapse-134.xht (1824B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: Margin Collapsing: clear with no 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/034.html" type="text/html"/> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins"/> 8 <link rel="match" href="margin-collapse-134-ref.xht" /> 9 10 <style type="text/css"> 11 table, td { padding: 0; border-spacing: 0; } 12 .comparator { border-spacing: 1em; } 13 .test, .control { border: solid; background: red; } 14 15 .test .container { display: block; background: yellow; margin: 0; width: 8em; } 16 .test .block { display: block; border-top: 1em solid lime; margin: 0 0 0 0; } 17 .test .clear { display: block; border-top: 1em solid green; margin: 1em 0 0 0; clear: right; } 18 19 .control .lime { background: lime; height: 1em; width: 8em; } 20 .control .yellow { background: yellow; height: 1em; width: 8em; } 21 .control .green { background: green; height: 1em; width: 8em; } 22 23 </style> 24 </head> 25 <body> 26 <p>The following three rectangles should be identical, with no red present.</p> 27 <table class="comparator"> 28 <tr> 29 <td class="test"> 30 <div class="container"> 31 <div class="block"> </div> 32 <div class="clear"> </div> 33 </div> 34 </td> 35 <td class="control"> 36 <div class="lime"> </div> 37 <div class="yellow"> </div> 38 <div class="green"> </div> 39 </td> 40 </tr> 41 <tr> 42 <td class="control"> 43 <div class="lime"> </div> 44 <div class="yellow"> </div> 45 <div class="green"> </div> 46 </td> 47 <td></td> 48 </tr> 49 </table> 50 51 52 </body> 53 </html>