top

Description »

Sets the location of the top edge of a non-static element.

Browser Compatibility
IE FF GC S O

Possible Values »

  • top: distance;
  • Distance from the top of the element defined by the position property.
  • top: auto;
  • Automatically places the top edge of the element. The default.
  • top: inherit;
  • Inherits the value from the parent element.

Details »

If the position of the element is absolute, then this moves the element from the top of the first non-static parent the value placed in distance.

If the position is relative, then this moves the element from the top of its normal position.

If the position is fixed, then this moves the element from the top of the browser window.

If the position is static, this property has no effect.

The distance can be in px, em, or a %. Furthermore, negative values are allowed.

Note: If both top and bottom are defined in the same selector, then the top value is taken.

In Practice »

Results CSS
Try it! at The CSS Zone Sandbox
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License