top CSS property specify an offset for the top edge of the positioned element, relative to the top edge of the reference element's box or browser window.
- For absolutely positioned elements, the
topproperty specifies how far the top edge of the element's box is offset below the top edge of its containing block.
- For relatively positioned elements, the
topproperty specifies the offset with respect to the top edge of the box itself (i.e., the box is given a position in the normal flow, and then offset from that position according to these properties).
The following table summarizes the usages context and the version history of this property.
|Applies to:||Positioned elements|
|Animatable:||Yes. See animatable properties.|
|Version:||CSS 2, 3|
The syntax of the property is given with:
The example below shows the
top property in action.
ExampleTry this code »
The following table describes the values of this property.
|length||Specifies the offset as a length value in
|percentage||Specifies the offset in percentage. The percentage is calculated with respect to the height of the element's containing block. Negative percentage values are allowed.|
||The browser calculates the top edge position. This is default value.|
||Sets this property to its default value.|
||If specified, the associated element takes the computed value of its parent element
top property is supported in all major modern browsers.