Geeks With Blogs
Woodbase Umbraco - CSS - jQuery - .Net - C#

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…

Posted on Tuesday, June 5, 2012 2:08 PM CSS | Back to top

Comments on this post: CSS–margin or padding

# re: CSS–margin or padding
Requesting Gravatar...
Thanks for sharing. I also often get these confused.
Left by Nick Harrison on Jun 06, 2012 4:33 PM

Your comment:
 (will show your gravatar)

Copyright © woodbase | Powered by: | Join free