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

margin112133.51
auto112163.51

We use cookies to improve your experience. Learn more in our Privacy policy.

×