CSS–margin or padding

Posted by woodbase on Geeks with Blogs See other posts from Geeks with Blogs or by woodbase
Published on Tue, 05 Jun 2012 12:08:18 GMT Indexed on 2012/06/05 16:41 UTC
Read the original article Hit count: 154

Filed under:

I was beginning the implementation of a new design, and once again I found that my margin property on a div-tag, did not behave as I expected. So I decided to look for best practice when it comes to using margin or padding.

What I found was this very short and concise description of the difference between the two:

“Margin is on the outside of block elements while padding is on the inside.

Use margin to separate the block from things outside it, padding to move the contents away from the edges of the block.”

So what is best practice? Well it depends on the context. In my case I should have used padding…

© Geeks with Blogs or respective owner