CSS margin-left Property

Description

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 value
0
Applies to
All elements
Inherited
No
Media
Visual
Computed value
As specified, but with relative lengths converted into absolute pixel values.
Animatable
Yes
CSS Version
CSS1, CSS2, CSS3
JavaScript syntax
object.style.marginLeft

Syntax

Formal syntax: <length> | <percentage> | auto

margin-left: 10px;
margin-left: 10%;
margin-left: auto;

Values

  • <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

Example

.class {
  margin-top: 1em;
  margin-right: 2em;
  margin-bottom: 3em;
  margin-left: 2em;
}

Give it a Try

Click the button below to experiment with this property.

Give it a Try!

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
312113.51
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
118410.11X