Quote:
Originally Posted by Francesco
Could someone please explain me the difference between margin and padding?
|
Padding:
If your element has a background color that background color would fill the content area and the padding area. i.e. it would be inside the "element". So padding separates the content from the border, like the packing material in a box.
Margin:
If you want to space an element from it's preceding element then margin would be the correct thing to use as it does just that: creates a margin between one element and the next. So margin is on the very outside, on the edge if you like.
If it helps to do it visually, think of an A4 page of type inside a picture frame.
The margin is the space between the edge of the sheet of paper and the other elements (the parts of the frame).
The padding is the space between the edge of the sheet and where the type starts on the page.
The border would be the edge of the sheet of paper.
Also see attached picture
Tad