We use cookies to improve your experience. Learn more in our Privacy policy.
margin
This property sets the margin area on all sides of an element. It is a shorthand for margin-top, margin-right, margin-bottom, and margin-left.
Example
Initial value | as each of the properties of the shorthand:margin-bottom: 0margin-left: 0margin-right: 0margin-top: 0 |
Applies to | all elements, except elements with table display types other than table-caption, table and inline-table. It also applies to ::first-letter and ::first-line. |
Syntax
margin: 10px;
Values
The size of the margin as a fixed value.
The size of the margin as a percentage, relative to the width of the containing block.
The browser selects a suitable margin to use. For example, in certain cases this value can be used to center an element.
Browser support
margin | 1 | 12 | 1 | 3 | 3.5 | 1 |
auto | 1 | 12 | 1 | 6 | 3.5 | 1 |