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
Ronnelle Torres
5,958 PointsI'm still confuse between margin and padding. What's the difference?
Please enlighten me in a simple way. Thanks! :) Because I'm still confuse between padding and margin. What's their difference? when will you use padding? when will you use margin?
Thanks!!
3 Answers
Kevin Korte
28,149 PointsGood question, yes there is a difference, and has to do with the box model. Once you understand the box model, you'll understand the difference, and when you should use margin or padding.
Padding is inside of the box model, margin is outside of the box model. Check this out: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model
LaToya Legemah
12,600 PointsIf you think of a box, margins are the spaces outside of the box. Padding is the spacing inside of a box. So if I have text in the box and I move the margins the entire box moves. If I add padding to the box, the entire box doesn't move but the space inside the box gets larger.
LaToya Legemah
12,600 PointsThis is a good explanation as well: http://www.impressivewebs.com/difference-between-margins-padding-css/
Ronnelle Torres
5,958 PointsThanks for clearing that up Latoya! :)
Ronnelle Torres
5,958 PointsRonnelle Torres
5,958 PointsWow! Thanks! The link you provided was very helpful! Cheers! :)