Margin, Border and Padding

What is the difference between Margin, Border, and Padding?

A margin refers to the area around the border, whereas padding refers to the area between an component's border and its content.

Use of Margin

  1. The margins allow the movement of the component; up or down, left or right. When margin value is set to auto, the component will be set in the centre when the page is in a fixed position.
  2. The margins set the whitespace. (Whitespace refers to spaces that have no characters, e.g. a tab)
  3. The margins allow the overlap of components with negative values.

Use of Padding

  1. The padding allows the addition of whitespace around the components and its border.
  2. The padding is able to alter the sizes of a component.

Use of Border

  1. Border is used to set a component's border. (Space around the component)
Margin, Border and Padding