Roughly the big difference is:
Margin / Margin - Spacing out of content.
Padding / Padding - Spacing within content limits.
HTML element styles are structured within a box called "The Box Model". Within that same box is the hierarchy:
Margin Box
Border Box
Padding Box
Element Box ( O elemento em si, div, span, entre outros )
Taking into account that the limit of the spacing of the content of an element is its border (border box). Therefore, the big difference in this case will be that the margin is already applied outside the element and will create spacing between the remaining elements, but the padding will create spacing within the element content itself, not affecting the spacing of the other elements.
Padding = Interior; Margin = Exterior
– Edilson
@Nottherealhemingway is not the same thing. The question cited refers to margin and padding in the Android context and here is in CSS. Even though the initial concepts are similar, it is valid to have the question redirected to CSS, so people can further explore this context in the answers.
– William Pereira
@Nottherealhemingway does not totally disagree with you, but there is a difference, the behavior in HTML+CSS of the box-model varies in certain situations, which is specific and does not occur in Android. That’s why although the question is simple still can generate good answers, in fact I hardly know anyone who understands box-model and so there are so many problems in web development, since the behavior of margin and padding vary from situation to situation in CSS. ;)
– Guilherme Nascimento