height-percentage-001

Percentage height computed to containing block

WeasyPrint

This browser

Assertion
A percentage height is calculated using the height of the containing block.

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: Percentage height computed to containing block</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#propdef-height">
 7         <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">
 8         <meta name="flags" content="">
 9         <meta name="assert" content="A percentage height is calculated using the height of the containing block.">
10         <style type="text/css">
11             #div1
12             {
13                 height: 2in;
14                 width: 2.1in;
15             }
16             div div
17             {
18                 width: 1in;
19             }
20             #div2
21             {
22                 background: blue;
23                 height: 50%;
24             }
25             #div3
26             {
27                 background: orange;
28                 height: 1in;
29                 left: 1in;
30                 position: relative;
31                 top: -1in;
32             }
33         </style>
34     </head>
35     <body>
36         <p>Test passes if the blue and orange boxes below are the same height.</p>
37         <div id="div1">
38             <div id="div2"></div>
39             <div id="div3"></div>
40         </div>
41     </body>
42 </html>