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 trialeric francis
5,705 PointsCan you talk about padding vs margin?
You've used padding and margin. What are the differences between the two? When do you decide to use one over the other?
2 Answers
Peter Szerzo
22,661 PointsHere is a simple way to start understanding the difference: if you apply a background color to an element that has both margins and padding, than the padding will get colored whereas the margin will not. I generally use margins to separate the elements of a webpage, and padding to add some 'breathing room' within an element - although this is not a hard and fast rule.
It is helpful to go over an explanation of the box model in css basics.
Joy Kesten
Treehouse Guest TeacherThis image may help as well: