The margin property is a shorthand tag to define all the margins of an element.
margin in CSS Versions:
A specific length (include unit of measure).
A percentage of the height of the closest block-level ancestor.
Allows the user-agent to define the margin based on inheritance and pre-set user-agent rules.
margin Initial Value:
margin Applies To:
This property is not inherited.
margin Browser Support:
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>
margin Special Notes:
- 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.