Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZoltan Parragi
6,007 PointsPadding or margin
A 68px top padding was added to the body. Instead of padding can I use 68px top margin? Has any significance using padding here and not margin?
2 Answers
Aurelian Spodarec
10,801 PointsKieran is correct.
Padding is from the inside, while margin is from the outside.
If you put say margin on a component that will have a background white, it will make a gap around the other components as much as you set the margin to be.
If you put say padding with a background white, the distance between other components will be the same, however there will be more white space.
Think about it this way:
Assume you're touching other human body to body with your front. If you put your arm in between, and take that arm out, you just created margin. You are now far from the person.
Now, back to where you werwe, and assume you gained size and say 100kg, and now you expanded from the inside, you now cover more space, but you're still toughing the other person.
Hope it helps!
Kieran Barker
15,028 PointsI think padding will add space inside the body
element, whereas margin will create space between body
and html
. I may be wrong, but Iβm on my iPad at the moment so I canβt double check inside my developer tools.
Zoltan Parragi
6,007 PointsTahnks, a lot.
Zoltan Parragi
6,007 PointsZoltan Parragi
6,007 PointsThanks, a lot.