margin-collapse-clear-016

Margin collapsing - margins of a 'collapsed through' box without clearance can collapse with parent block's bottom margin

WeasyPrint

This browser

Assertion
An element that does not have clearance applied to it can collapse its top margin with its parent block's bottom margin. Margins of a 'collapsed through' box without clearance applied to it can collapse with its parent block's bottom margin. An element with clear set to it (to other than 'none') can only create a clearance if and when there is a preceding floated block.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3 
 4  <head>
 5 
 6   <title>CSS Test: Margin collapsing - margins of a 'collapsed through' box without clearance can collapse with parent block's bottom margin</title>
 7 
 8   <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">
 9   <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
10   <link rel="author" title="Daniel Schattenkirchner" href="crazy-daniel{at}gmx.de">
11   <meta content="An element that does not have clearance applied to it can collapse its top margin with its parent block's bottom margin. Margins of a 'collapsed through' box without clearance applied to it can collapse with its parent block's bottom margin. An element with clear set to it (to other than 'none') can only create a clearance if and when there is a preceding floated block." name="assert">
12   <meta content="" name="flags">
13 
14   <style type="text/css">
15   body
16   {
17   background-color: white;
18   }
19 
20   #parent-block
21   {
22   background-color: red;
23   margin-bottom: 0px;
24   }
25 
26   #sibling
27   {
28   background-color: green;
29   height: 100px;
30   }
31 
32   #element-without-clearance-applied
33   {
34   clear: both;
35   margin-top: 100px;
36   }
37   </style>
38 
39  </head>
40 
41  <body>
42 
43   <p>Below, there should be a green rectangle across the page. There should be no red in this page.</p>
44 
45   <div id="parent-block">
46    <div id="sibling"></div>
47    <div id="element-without-clearance-applied"></div>
48   </div>
49 
50   <!--
51   #element-without-clearance-applied's margin-top collapses with #parent-block's margin-bottom: the resulting margin-bottom then collapses with the adjoining white body's margin-bottom
52   -->
53 
54  </body>
55 </html>