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 trial2 Answers
Vitor Freitas
3,579 PointsDefines the spacing between the content of the element and its border.
Unsubscribed User
5,512 PointsAs Vitor has stated, padding adds spacing between the content (img, h1, h2, p, etc) and its border.
When I first started learning about CSS, I often confused margin and padding. The way I was able to understand it was to think about padding in a literal sense e.g. "padding the element" or, in other words, adding more "stuff" to the element. Margin, on the other hand, can be thought of "pushing/pulling elements apart/closer" (positive/negative margin) to one other.
Check out this CodePen example I made up for you.
Hope this helps! :)
-Stu
Martina Vonkomerova
7,790 PointsThank you Stuart!
Martina Vonkomerova
7,790 PointsThank you Stuart!
Martina Vonkomerova
7,790 PointsMartina Vonkomerova
7,790 PointsObrigado Vitor!