width-percentage-001

Calculating percentage based width off of the parent container

WeasyPrint

This browser

Assertion
Percentage is calculated with respect to the width of the generated boxes 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: Calculating percentage based width off of the parent container</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#the-width-property">
 7         <meta name="flags" content="">
 8         <meta name="assert" content="Percentage is calculated with respect to the width of the generated boxes containing block.">
 9         <style type="text/css">
10             div
11             {
12                 height: 1in;
13             }
14             #div1
15             {
16                 width: 2in;
17             }
18             div div
19             {
20                 background-color: orange;
21                 width: 50%;
22             }
23             #div2
24             {
25                 background-color: blue;
26                 width: 1in;
27             }
28         </style>
29     </head>
30     <body>
31         <p>Test passes if the orange and blue boxes are the same width.</p>
32         <div id="div1">
33             <div></div>
34         </div>
35         <div id="div2"></div>
36     </body>
37 </html>