Using individual margin properties
This div element has a top margin of 100px, a right margin of 150px, a bottom margin of 100px, and a left margin of 80px.
The margin shorthand property - 4 values
This div element has a top margin of 25px, a right margin of 50px, a bottom margin of 75px, and a left margin of 100px.
The margin shorthand property - 3 values
This div element has a top margin of 25px, a right and left margin of 50px, and a bottom margin of 75px.
The margin shorthand property - 2 values
This div element has a top and bottom margin of 25px, and a right and left margin of 50px.
The margin shorthand property - 1 value
This div element has a top, bottom, left, and right margin of 25px.
Use of margin: auto
You can set the margin property to auto to horizontally center the element within its container. The element will then take up the specified width, and the remaining space will be split equally between the left and right margins:
This div will be horizontally centered because it has margin: auto;
Use of the inherit value
Let the left margin be inherited from the parent element:
This paragraph has an inherited left margin (from the div element).