CSS top property
Browser support · legacy reference
ChromeFully supports
SafariFully supports
FirefoxFully supports
Internet ExplorerFully supports
EdgeFully supports
OperaFully supports
Description
CSS top property represents the distance of top side of current box either from the top side of parent box or from the original position depending upon the value of position property.
The current element should have position property otherwise top property will not work. We apply position: absolute; property to the current element.
Syntax
top : auto | length | percentage
Property values
length
-
It represents the distance of the top side of the current box from the top side of the parent box.
The box is 100px away from the top side of the parent box (absolute position).
- Try it
top: 100px; percentage
-
Actually percentage represents height of the parent box.
The box is 20% away from the top side of the parent box (absolute position).
- Try it
top: 20%;
Applicable to
It applies to all elements