CSS margin Property

CSS margins are used to make room around an element. We can change the margin sizes for individual sides (top, right, bottom, left).

The following values can be assigned to margin properties:

  • Length in cm, px, pt, and so on.
  • The element's width as a percentage.
  • The browser calculates the margin: auto.




Property Values

Value Description
margin-top This property is used to specify the top margin of an element.
margin-right This property is used to specify the right margin of an element.
margin-bottom This specifies how much margin should be used at the bottom of an element.
margin-left This property specifies the width of the margin to the left of the selected element.

Supported Browsers

Property Chrome Firefox Safari Edge / IE Opera
margin 1.0 1.0 1.0 6.0 3.5
JavaScript Coming Soon...