+ 1

Difference between margin and padding?

What's the difference between margin, padding, border and actual content in CSS?

2nd Mar 2017, 7:29 PM
Caway
Caway - avatar
5 Answers
+ 7
Padding is the space around the content, and the border is followed - if specified - around this; the margin is the space around all of them combined. Google box-sizing for some useful information, because this is where some developers have issues causing the element to collapse/spill or look odd when designing.
2nd Mar 2017, 7:52 PM
Mark Foxx
Mark Foxx - avatar
+ 3
Search for images of the html box model, it describes the terms better than words.
2nd Mar 2017, 7:37 PM
Mario L.
Mario L. - avatar
0
Remembering divs are boxes...margins happen outside the box, padding happens inside the box
3rd Mar 2017, 5:42 AM
Jason Lewis
Jason Lewis - avatar
0
let's say you have a house yh, so the DISTANCE or SPACE from a main road to your fence is the MARGIN and your fence can be seen as the BORDER, the DISTANCE or SPACE from your fence to your HOUSE is the PADDING. Your HOUSE is the content
8th Mar 2017, 11:37 AM
Junior ab
Junior ab - avatar