margin-collapse-017

Margin collapsing - parent edge and element edge are the same when margins collapse

WeasyPrint

This browser

Assertion
When the top margin of a child box collapses with the top margin of its parent, then the margin-top edge of such child box is the same as the parent's and their respective content should be 'sitting' at the parent's border-bottom (in the testcase, the black line) assuming the same height value and the same padding-bottom value for the parent and its child box.

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 - parent edge and element edge are the same when margins collapse</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="">
 8         <meta name="assert" content="When the top margin of a child box collapses with the top margin of its parent, then the margin-top edge of such child box is the same as the parent's and their respective content should be 'sitting' at the parent's border-bottom (in the testcase, the black line) assuming the same height value and the same padding-bottom value for the parent and its child box.">
 9         <style type="text/css">
10             #div1
11             {
12                 border-bottom: solid;
13             }
14             div div
15             {
16                 height: 20px;
17                 margin-top: 60px;
18                 width: 60px;
19             }
20             #div2
21             {
22                 background: red;
23             }
24             #div3
25             {
26                 background: blue;
27             }
28         </style>
29     </head>
30     <body>
31         <p>Test passes if the blue box is touching the line and there is no red visible on the page.</p>
32         <div id="div1">
33             <div id="div2">
34                 <div id="div3"></div>
35             </div>
36         </div>
37     </body>
38 </html>