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
Mohd Maqbool Alam
Full Stack JavaScript Techdegree Student 5,715 PointsPadding and Margin
what is the difference btw padding and margin i m not able to understand in the video
3 Answers
Shawn McGrory
546 PointsPadding creates a margin inside an element:
http://www.w3schools.com/css/tryit.asp?filename=trycss_padding_shorthand
A margin is on the outside:
http://www.w3schools.com/css/tryit.asp?filename=trycss_margin_sides
Ben Singer
8,621 PointsPadding goes inside an element and (generally) expands the size of the element, margin is the space outside the element and pushes the element away from other elements.
Here's a bad analogy:
Think of padding as pillows going into a box, the more pillows go in, the more the box has to expand to accommodate them.**
Think of margin as having two boxes -- when you're pushing them away from each other, you're increasing the margin between those elements.
** Unless you're using box-sizing:border-box; but that's something else.
Mohd Maqbool Alam
Full Stack JavaScript Techdegree Student 5,715 Pointsi got it thanks !