When to use margin vs padding in CSS When writing CSS, is there a particular rule or guideline that should be used in deciding when to use margin and when to use padding? Solution : TL;DR: By default I use margin everywhere, except when I have a border or background and want to increase the space inside that visible box. To me the biggest difference between padding and margin is that vertical margins auto-collapse, and padding doesn't. Consider two elements one above the other each with padding of 1em.