top-offset-001

Position 'top' property defines the offset from the top edge of the containing block for absolute positioning

WeasyPrint

This browser

Assertion
The 'top' property, for absolute positioning, specifies the offset of the element in relation to the containing block's top edge. The containing block of an absolutely positioned element is formed by the padding box of its nearest (closest) positioned ancestor element.

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: Position 'top' property defines the offset from the top edge of the containing block for absolute positioning</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#propdef-top">
 7         <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#position-props">
 8         <meta name="flags" content="">
 9         <meta name="assert" content="The 'top' property, for absolute positioning, specifies the offset of the element in relation to the containing block's top edge. The containing block of an absolutely positioned element is formed by the padding box of its nearest (closest) positioned ancestor element.">
10         <style type="text/css">
11             div
12             {
13                 height: 1in;
14                 position: relative;
15                 width: 1in;
16             }
17             #div1
18             {
19                 background: blue;
20             }
21             #div2
22             {
23                 background: white;
24                 height: 0.5in;
25                 position: absolute;
26                 top: 0.5in;
27                 width: 0.5in;
28             }
29         </style>
30     </head>
31     <body>
32         <p>Test passes if there is a box below with its bottom-left corner missing.</p>
33         <div>
34             <div id="div1"></div>
35             <div id="div2"></div>
36         </div>
37     </body>
38 </html>