Margin Syntax

The margin property sets the margins for an element, and is a shorthand property for the following properties:

CSS Syntax

margin: length|auto|initial|inherit;
  • margin-top
  • margin-right
  • margin-bottom
  • margin-left
Top Of Form
Four Commands

If the margin property has four values:

CSS Syntax

margin: 10px 5px 15px 20px;
  • top margin is 10px
  • right margin is 5px
  • bottom margin is 15px
  • left margin is 20px
Top Of Form
Three Commands

If the margin property has three values:

CSS Syntax

margin: 10px 5px 15px;
  • top margin is 10px
  • right and left margins are 5px
  • bottom margin is 15px
Top Of Form
Two Commands

If the margin property has two values:

CSS Syntax

code section
  • top and bottom margins are 10px
  • right and left margins are 5px
Top Of Form
One Command

If the margin property has one value:

CSS Syntax

margin: 10px;
  • all four margins are 10px
Top Of Form

---

Note: Negative values are allowed.