1Margin is on the outside of block elements, padding is on the inside.
2
3Use margin to separate the block from things outside it
4Use padding to move the contents away from the edges of the block.
5
6Main differences:
7- Vertical margins of adjacent items will overlap, padding will not
8- Padding is included in the click region and background color/image,
9but not the margin
1padding is the space between the content and the border,
2whereas margin is the space outside the border.
1/* Answer to: "css padding vs margin" */
2
3/*
4 Margin is outer space of an element, while padding is inner space
5 of an element. Margin is the space outside the border of an
6 element, while padding is the space inside the border of it.
7 Margin accepts the value of auto: margin: auto , but you can't
8 set padding to auto.
9
10 For more information, head over to:
11 https://stackoverflow.com/questions/2189452/when-to-use-margin-vs-padding-in-css
12*/