The top property sets the vertical inset of a positioned element. It has no effect when position is static (the default).
With absolute or fixed, top is the distance from the containing block’s top edge. With relative, it moves the element down from its normal place. With sticky, it helps define the sticky constraint.
Standard-track.
Baseline widely available. Not deprecated as a property.
Limited support.
anchor() / anchor-size() values belong to CSS Anchor Positioning and are newer—skip them until you need that feature.
Enable sticky.position: sticky mixes relative flow with a stick point.
Set the stick inset.top: 0 means stick when the top of the scrolling area is reached.
Need a non-auto inset. Sticky on an axis requires a non-auto inset such as top.
Scroll ancestor. Sticky uses the nearest scroll container—overflow on a parent can change the effect.
Edge Cases & Pitfalls
If top seems to do nothing, one of these is usually why.
static
Ignored on position: static
The default position is static. Set a non-static position before expecting any inset.
%
Percentages need a definite height
top: 10% uses the containing block’s height. If that height is auto/indefinite, the percentage may resolve to unexpected results.
bottom
top vs bottom conflict
On relative boxes (or when height is constrained), top wins and bottom is ignored. On absolute/fixed with height auto, both can stretch the element.
margin
Do not confuse with margin-top
margin-top pushes in the box model. top offsets a positioned element. They solve different problems.
sticky
Sticky needs a non-auto inset
Without a length/percentage on top (or the matching inset), sticky will not stick on that axis.
Compatibility
Browser Support
top is a browser CSS property for positioned layout insets. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available since Jul 2015
top
Length, percentage, and auto: all modern browsers and Internet Explorer. Anchor-positioning functions (anchor()) are newer and separate from everyday use.
97%Global support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera6+
Full support
Samsung Internet1+
Full support
Internet Explorer5+
Full support
topWidely supported
Bottom line: Safe everywhere for everyday positioning. Learn sticky and absolute containing blocks separately—those behaviors depend on position, not on top alone.
Remember
Key Takeaways
Role: vertical inset for positioned elements only.
Initial value:auto. Not inherited.
Prerequisite: non-static position.
Pitfall: percentages use containing-block height, not the element’s own height.
One line: set position first, then use top to place the element vertically.
Frequently Asked Questions
It sets the vertical inset of a positioned element. For absolute or fixed, that is the distance from the containing block’s top edge. For relative, it moves the element down from its normal spot.
auto. The browser does not apply a forced vertical inset until you set a length or percentage.
No. On position: static (the default), top has no effect. Use relative, absolute, fixed, or sticky first.
For absolute or fixed with height auto, both can stretch the box. For relative (or when height is fixed), top wins and bottom is ignored.
No. margin-top adds spacing in the box model. top offsets a positioned element relative to its containing block or normal position.
Universally supported in modern browsers and Internet Explorer for length, percentage, and auto. It is a browser CSS property, not a Node.js feature.