CSS margin-left property
Example
Set the left margin of a p element:
p
{
margin-left:
2
cm
;
}
Try it »
Property definition and usage
The margin-left property sets the left margin of an element.
Note: Negative values are allowed.
| Default value: | 0 |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object.style.marginLeft="10px" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| margin-left | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
Attribute values
| Value | Description |
|---|---|
| auto | The browser sets the left margin. |
| length | Defines a fixed left margin. The default value is 0. |
| % | Defines a left margin as a percentage of the parent element's total width. |
| inherit | Specifies that the left margin should be inherited from the parent element. |
Related Articles
CSS Tutorial: CSS Margin