It's good to know the differences between margin
and padding
. Here are some differences:
- Margin is outer space of an element, while Padding is inner space of an element.
- Margin is the space outside the border of an element, while Padding is the space inside the border of it.
-
Margin accepts the value of auto:
margin: auto
, but you can't set Padding to auto. - Margin can be set to any number, but Padding must be non-negative.
- When you style an element, Padding will be affected also (e.g. background color), but not Margin.