What is different between margin and padding? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What is different between margin and padding?

17th Jan 2016, 8:47 PM
Tkachuk Yevhen
Tkachuk Yevhen - avatar
9 Answers
+ 19
margin is the space an element take from its outside and padding is the space it takes from inside.
1st Feb 2016, 9:03 AM
Sharan
Sharan - avatar
+ 10
Margin is the space between the border of the element with the border of other elements whereas padding is the area between the content and border of the element
18th Feb 2017, 11:10 AM
Siddharth Saraf
+ 3
Padding is space between content and border. Margin is space between border and another element. Suppose a box has a object inside it, here six walls of box is border and object inside it is content for CSS. Padding is space between object and walls of box(there may be different padding/space from different sides). If you keep that box in your cupboard little bit away from another box or even wall of cupboard, that space is margin of box.
5th Nov 2016, 2:11 AM
Namas Thapa
Namas Thapa - avatar
+ 2
Padding is physical white space that objects obey. Margin is transparent space where other objects can be placed
13th Mar 2016, 6:31 PM
Kris Kelley
Kris Kelley - avatar
+ 2
if you ad a background color it will cover padding and not margin.
24th Jul 2016, 5:41 AM
Derek Venuto
Derek Venuto - avatar
+ 2
Basically margin is the outer most part of a box model. Padding is deep inside coming only after the border.
30th Aug 2016, 9:48 AM
Chirag Bhansali
Chirag Bhansali - avatar
+ 1
margin is the space taken before the border of a box & padding is the space specified inside of a box
22nd Oct 2016, 11:33 PM
Germain Kevin
Germain Kevin - avatar
0
Margin represent the space between elements. whereas padding is a space inside the element which holds the content away from the edges of the box.
15th Nov 2016, 7:52 AM
shan
- 6
No difference. both are spacing left out from edges of, say, a paper, a square, a box, a division etc, so that your contents won't get too close , and looks better!
14th Jul 2016, 5:48 AM
Alexis Cheuk Yan Lee
Alexis Cheuk Yan Lee - avatar