Hacker News new | ask | show | jobs
by gyrgtyn 2279 days ago
You could argue that margins are part of the element, just like padding and border are, so
2 comments

You could, but this mental model probably won't be as helpful as thinking of margin as the element pushing its neighbors away (or pushing itself away).

It's hard to define margin without any relation to neighboring elements, it's easy for padding and border. It seems logical that a reusable component shouldn't make assumptions about its neighbors, therefore avoid margins on its boundaries.

Margin is usually added in response to nearby elements. Making assumptions about nearby elements is what makes components hard to reuse.