What is the difference between margin and padding in CSS?
Padding sets space between a border and an element content. Margin sets space between a border and other outer elements.
When elements need space between them it's better to use margin. When text or inner elements need space between the parent element (box) and the text itself, then padding should be used.
Read more about it in the following article: how to set margins and paddings in CSS.