The margin-leftCSS property of an element sets the margin space required on the left side of a box associated with an element. A negative value is also allowed.
The vertical margins of two adjacent boxes may fuse. This is called margin collapsing.
In the rare cases where width is overconstrained (that is when all of width, margin-left, border, padding, the content area and margin-right are defined), margin-left is ignored, and will have the same calculated value as if the auto value was specified.
margin-left: 10px; /* An absolute length */
margin-left: 1em; /* A length relative to the text size */
margin-left: 5%; /* A margin relative to the nearest block container's width */
Is a <length> specifying a fixed width: it can be absolute width, e.g. in px, or a width relative to the text size, e.g. in em, or relative to the viewport size, e.g. in vh.
Is a <percentage> relative to the width of the nearest containing block.
Is a keyword indicating that the left margin receives a share of the remaining space, defined mainly by the current layout mode.. If there several auto values for margin-left or margin-right, the calculated space is evenly distributed between all the auto values. This table summarizes the different cases:
Thanks! Please check your inbox to confirm your subscription.
If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.
Why does MDN look different?
MDN is changing to focus just on documenting web technologies. All the same great content is still here; we’re just changing some visual elements and navigation, to help you more quickly find the web technology docs you’re looking for.
But don’t worry, MDN and Mozilla are still together! In fact, we're updating MDN’s look to reflect Mozilla's new logo and colors.