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 trialDiane Ancheril
1,109 PointsMargin and padding
What is the difference between margin and padding?
3 Answers
Martin Foldyna
10,359 PointsHi, with padding you expanding the inner space of the div/button or whatever. With margin you are giving more space to the outside of the div/button/photo etc... Hope it's not confusing what I wrote.
Ari Frankel
Courses Plus Student 5,438 PointsDiane Ancheril
1,109 PointsThanks so much, you guys! All your answers were very helpful.
Joey Ward
Courses Plus Student 24,778 PointsJoey Ward
Courses Plus Student 24,778 PointsA margin adds space between the OUTSIDE of an element and the surrounding elements. Padding adds space INSIDE of an element (between the border and the element's content). Try adding a thick border to an element and playing with margin and padding. You will quickly notice the difference. Also try hitting F12 to use developer tools on your browser. There will be a box that illustrates the difference and provides you with values. In Chrome, click on the "Computed" tab in your developer tools to see this in action.