The margin-left property of an element sets the margin space required on the left 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 syntaxobject.style.marginLeft
Formal syntax: <length> | <percentage> | auto

margin-left: 10px;
margin-left: 10%;
margin-left: 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!

1+Firefox6+Explorer1+Chrome1+Safari8+Opera


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.