HomeReferencesCSS Properties

CSS Property: margin, margin-top, margin-right, margin-bottom, margin-left

Specifies the margin around a box.

HTML Dog, The Book HTML Dog book cover

HTML Dog is hosted by Titan Internet

Possible Values

  • [percentage]
  • [length]
  • inherit
  • auto
  • margin can have:
    • one value such as 10px to specify an equal margin on every side
    • two values, such as 10px 5px, to specify the top/bottom (first value) and right/left (second value) margin
    • three values, such as 10px 5px 2px, to specify the top (first value), right/left (second value) and bottom (third value) margin
    • four values, such as 10px 5px 2px 1px to specify the top, right, bottom and left margins respectively

Example


#badger { margin-top: 3em; }

#wolverine { margin: 1em 100px; }

#pineapple { margin: 1em 3em 10px 0.5em; }