A CSS Mnemonic
Monday, June 30th, 2008One of the things that used to annoy me about working with CSS, is that I had a mental block about margin and padding. I could never recall which was which, because the two terms mean pretty much the same thing; an arbitrary space around text. Frankly I think the creators of CSS should have used have called them inner-margin and outer-margin, or inner-padding and outer-padding. I’m sure there is a good reason for using the terms margin and padding (I’m guessing its from typesetting nomenclature), but to me they feel arbitrary and may have well have been called bob and jane.
Fortunately I came up with a mnemonic that made it click. Just remember the phrase ‘padded cell’. In a padded cell, the padding goes on the inside. So there you have it, you’ll never again forget that the box model is text -> padding -> border -> margin.
