The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent.
The top, right, bottom, and left margin can be changed independently using separate properties. A shorthand margin property can also be used, to change all margins at once.
Possible Values
| Value | Description |
auto |
The browser sets the margin. |
length |
Defines a fixed margin (in pixels, pt, em, etc.) |
% |
Defines a margin in % of the containing element |
It is possible to use negative values, to overlap content.
Margin - Individual sides
In CSS, it is possible to specify different margins for different sides:
Example
|