The margin property is a shorthand tag to define all the margins of an element.
margin: [ <length> | <percentage> | auto ]{1,4}
margin: <margin-top> <margin-right> <margin-bottom> <margin-left>
- length
A specific length (include unit of measure). - percentage
A percentage of the height of the closest block-level ancestor. - auto
Allows the user-agent to define the margin based on inheritance and pre-set user-agent rules.
Not defined
All elements.
This property is not inherited.
set all margins
<p style="margin : 2em;">
This paragraph has a 2 em margin on all sides.
</p>
set top and bottom the same and right and left the same
<p style="margin : 2em 1em;">
This paragraph has a 2 em margin on the top and bottom and a 1em margin on the right and left.
</p>
- Negative values are permitted, but may be affected by implementation limits.
- If only 3 values are listed, the left margin is assumed to be the same as the right.

