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

CSS

Padding and Margin

what is the difference btw padding and margin i m not able to understand in the video

3 Answers

Padding 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.

i got it thanks !