CSS margin-left property

Definition and Usage

The margin-left property sets the left outer margin of the element.

Note:Negative values can be used.

See Also:

CSS Tutorial:CSS Margin

HTML DOM Reference Manual:marginLeft Property

Examples

Set the left outer margin of the p element:

p
  
  margin-left:2cm;
  }

Try It Yourself

(More examples can be found at the bottom of the page)

CSS Syntax

margin-left: length|auto|initial|inherit;

Property Value

Value Description
auto The left outer margin set by the browser.
length Specifies a fixed left outer margin. The default value is 0.
% Specifies the left outer margin as a percentage of the width of the containing element.
inherit Specifies that the left outer margin should be inherited from the parent element.

Technical Details

Default Value: 0
Inheritance: no
Version: CSS1
JavaScript Syntax: object

More Examples

Set the left outer margin of text to 1
This example demonstrates how to set the left margin of text using centimeter values.
Set the left outer margin of text to 2
This example demonstrates how to set the left margin of text using percentage values.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome IE / Edge Firefox Safari Opera
1.0 6.0 1.0 1.0 3.5