How to remember in CSS that margin is outside the border, and padding inside

Hamish Downer picture Hamish Downer · Aug 28, 2008 · Viewed 14.6k times · Source

I don't edit CSS very often, and almost every time I need to go and google the CSS box model to check whether padding is inside the border and margin outside, or vice versa. (Just checked again and padding is inside).

Does anyone have a good way of remembering this? A little mnemonic, a good explanation as to why the names are that way round ...

Answer

Simon Keep picture Simon Keep · Aug 28, 2008

When working with CSS finally drives you mad the padded cell that they will put you in has the padding on the inside of the walls.