HTML Dog
Skip to navigation

CSS Property: top

The top position of a box.

Calculated differently, depending on the position state of a box.

For relative positioned boxes, top defines how far the box is offset from its initial top edge. So a positive value will, in fact, shift the box down.

For absolute (or fixed) position boxes, top defines how far the box is offset from the top edge of its containing block (being the page or a containing positioned box).

Possible Values

ValueNoteExample
[length]100px
[percentage]Calculated in relation to the height of the containing box.50%
autoDefault.
inherit
initial
unset

Example


#forsale {
    position: absolute;
    top: 25%;
}

Browser support