The margin-top property of an element sets the margin space required on the top of an element. A negative value is also allowed.

  • Initial value0
  • Applies toAll elements
  • InheritedNo
  • MediaVisual
  • Computed valueAs specified, but with relative lengths converted into absolute pixel values.
  • AnimatableYes
  • CSS VersionCSS1, CSS2, CSS3
  • JavaScript
Formal syntax: <length> | <percentage> | auto

margin-top: 10px;
margin-top: 10%;
margin-top: auto;
  • <length>Specifies a fixed length, using any standard CSS length units. Negative Values are allowed.
  • <percentage>A percentage always relative to the width of the containing block.
  • inherit
.class {
  margin-top: 1em;
  margin-right: 2em;
  margin-bottom: 3em;
  margin-left: 2em;

Click the button below to experiment with this property.

Give it a Try!


Last updated on 23rd March 2014 By Rene Spronk

View All CSS Properties

Errors? Please help to keep this list up to date, If you find any errors, please contact us, so that we can get them fixed.