margin-collapse-029

Margin collapsing - position of top border edge for elements that collapse margins with parents not participating in margin collapsing

WeasyPrint

This browser

Assertion
When margins collapse through empty elements and the parent element is not participating in margin collapsing then the position of the elements top border should be in the same position as if the element had a top border specified.

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 - position of top border edge for elements that collapse margins with parents not participating in margin collapsing</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 margins collapse through empty elements and the parent element is not participating in margin collapsing then the position of the elements top border should be in the same position as if the element had a top border specified.">
 9         <style type="text/css">
10             div
11             {
12                 width: 5em;
13             }
14             #div1
15             {
16                 border-top: 1em solid black;
17             }
18             #div2
19             {
20                 margin-top: 2em;
21                 margin-bottom: 4em;
22                 position: absolute;
23                 background: black;
24                 height: 1em;
25             }
26             #div3
27             {
28                 height: 0;
29                 margin-top: 2em;
30                 margin-bottom: 2em;
31             }
32             #div4
33             {
34                 margin-top: 3em;
35                 margin-bottom: 2em;
36                 border-top: 1em solid black;
37             }
38         </style>
39     </head>
40     <body>
41         <p>Test passes if there are three evenly-spaced black boxes stacked on the page.</p>
42         <div id="div1">
43             <div id="div2">
44                 <div id="div3"></div>
45                 <div id="div4"></div>
46             </div>
47         </div>
48     </body>
49 </html>