Spacings (Margin)

Introduction

The margin properties are used to generate space around elements.

Margin is on the outside of block elements while padding is on the inside:

  • Use margin to separate the block from things outside it.
  • Use padding to move the contents away from the edges of the block.

Take a look at the following screenshot. Light blue area specifies 70px padding-top and light green specifies 70px margin-bottom.

Margin Properties

Property Values Description
Margin Top value Sets the left margin of an element.
Margin Right value, auto Sets the right margin of an element.
Margin Bottom value Sets the top margin of an element.
Margin Left value, auto Sets the bottom margin of an element.
Was this article helpful?
YesNo
Live Editor