margin-collapse-018

Margin collapsing - element with clearance

WeasyPrint

This browser

Flags
ahem, image
Assertion
An element that has clearance applied to it will not collapse its top margin with its parent's bottom margin.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3     <head>
 4         <title>CSS Test: Margin collapsing - element with clearance</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">
 7         <meta name="flags" content="ahem image">
 8         <meta name="assert" content="An element that has clearance applied to it will not collapse its top margin with its parent's bottom margin.">
 9         <style type="text/css">
10             div
11             {
12                 font: 20px/1em Ahem;
13                 width: 5em;
14             }
15             #div1
16             {
17                 background: url('support/margin-collapse-4em-space.png');
18                 height: 6em
19             }
20             .class1
21             {
22                 background: green;
23                 height: 1em;
24             }
25             #div2
26             {
27                 margin-bottom: 1em;
28             }
29             #div3
30             {
31                 float: left;
32                 height: 3em;
33             }
34             #div4
35             {
36                 clear: both;
37                 margin-top: 1em;
38             }
39         </style>
40     </head>
41     <body>
42         <p>Test passes if there is no red visible on the page.</p>
43         <div id="div1">
44             <div class="class1"></div>
45             <div id="div2">
46                 <div id="div3"></div>
47                 <div id="div4"></div>
48             </div>
49             <div class="class1"></div>
50         </div>
51     </body>
52 </html>