CSS position top property
CSS Position top Property
Description
The top property defines the offset of an absolutely positioned element from the top edge of its positioning context, or the vertical displacement of a relatively positioned element.
Possible Values
- length − A fixed distance from the top edge of the positioning context.
-
percent − A percentage relative to the positioning context’s height, assuming the context’s height has been explicitly set. If not set, the top percentage is treated as auto.
-
auto − Default value. Let the browser calculate the top position.
Applies to
All HTML positioned elements.
DOM Syntax
object.style.top = "2px";
Example
Below is an example showing the effect of this property –
<html>
<head>
</head>
<body>
<p style = "position:absolute; top:100px;">
This line will be positioned 100px below from the top edge of this window.
</p>
</body>
</html>
It will produce the following result −