1. Computing

Discuss in my forum

What is the difference between padding and margins?

By

Question: What is the difference between padding and margins?
Answer:

Margins and padding can be confusing to the novice Web designer. After all, in some ways, they seem like the same thing: white space around an image or object.

Padding is the space inside the border between the border and the actual image or cell contents. In the image, the padding is the yellow area around the contents. Note that padding goes completely around the contents: there is padding on the top, bottom, right and left sides.

Margins are the spaces outside the border, between the border and the other elements next to this object. In the image, the margin is the red area outside the entire object. Note that, like the padding, the margin goes completely around the contents: there are margins on the top, bottom, right, and left sides.

Keep in mind, if you are planning on doing really fancy things with margins and padding, that Internet Explorer doesn't implement the box model correctly. This means that your pages will look different (and sometimes vastly different) in other browsers.

More about the CSS box model, the margin property, and the CSS style library.

©2014 About.com. All rights reserved.