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 trialabdirahman liban
Courses Plus Student 2,163 Pointsmargin and padding confusion
after I watched many courses of html and css in treehouse I'm still confused about margin and padding
3 Answers
Erik S.
9,789 PointsPadding is applied to the inside of the border of your element so you can control how far the content is away from the border.
Margin is applied to the outside of the border of your element, so you can control how far the element is away from other elements.
Special usage: if you use a negative margin, you can pull the element closer to other elements. and also good to keep in mind: padding will increase the dimensions of your element, whereas margin won't.
John Satterfield
13,695 PointsErik Schmok explained the differences very well.
If you need further explanation and examples you can always reference the w3schools website on padding and margins here: http://www.w3schools.com/css/css_margin.asp http://www.w3schools.com/css/css_padding.asp http://www.w3schools.com/css/css_boxmodel.asp
Benjamin Hedgepeth
5,672 PointsPadding: Space in between the content and the content box edge.
Margin: Space set around the border box (content box + padding (optional) + border) relative to other elements.
Samuel Essim
Front End Web Development Techdegree Student 15,963 PointsSamuel Essim
Front End Web Development Techdegree Student 15,963 PointsThanks a lot Erik . The information you gave iss very helpful.