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 trial
Mani Saini
3,101 PointsDifference between Margin and Padding
What is the difference between Margin and Padding for an element? Please explain using an example, Thanks.
2 Answers
Evan Demaris
64,262 PointsHi Mani,
Padding defines the space between the element border and the element content.
Margin defines the space around elements. The margin clears an area around an element (outside the border).
Hope that helps!
jason chan
31,009 Pointsmargin is outside space and padding is inside space.
I hope that helps.
https://www.smashingmagazine.com/2009/10/mastering-css-coding-getting-started/#CSS-Basics1
Mani Saini
3,101 PointsThanks Jason

Mani Saini
3,101 PointsMani Saini
3,101 PointsThanks Evan