Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between padding and margin?

In W3 CSS and also in XUL/CSS? (not between CSS and XUL/CSS).

like image 420
Pablo Avatar asked May 13 '10 01:05

Pablo


People also ask

Is it better to use margin or padding?

Use a margin when you want to adjust the spacing of an element and use padding when you want to adjust the appearance of the element itself. Margins aren't a part of the element; padding is.

What are margins and padding?

margin and padding are the two most commonly used properties for spacing-out elements. A margin is the space outside something, whereas padding is the space inside something.

What is the difference between margin and padding in coding?

Margin is the outer space of an element, while padding is the inner space of an element. In other words, margin is the space outside of an element's border, while padding is the space inside of its border.


1 Answers

I recommend this article for you. The diagram is from that article.

alt text

http://elegantcode.com/2010/01/26/css-basics-the-box-model/

like image 57
Srikar Doddi Avatar answered Oct 04 '22 03:10

Srikar Doddi