margin-collapse-004

Margin collapsing - negative margins deducted from zero

WeasyPrint

This browser

Assertion
Negative margins are deducted from zero if no positive margins are adjoining.

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 - negative margins deducted from zero</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="Negative margins are deducted from zero if no positive margins are adjoining.">
 9         <style type="text/css">
10             div div
11             {
12                 height: 20px;
13             }
14             #div1
15             {
16                 background: blue;
17                 margin-bottom: 0;
18             }
19             #div2
20             {
21                 background: orange;
22                 margin-top: -40px;
23             }
24         </style>
25     </head>
26     <body>
27         <p>Test passes if the orange box is above the blue box.</p>
28         <div>
29             <div id="div1"></div>
30             <div id="div2"></div>
31         </div>
32     </body>
33 </html>