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

Difference between Margin and Padding

What is the difference between Margin and Padding for an element? Please explain using an example, Thanks.

2 Answers

Hi Mani,

Padding defines the space between the element border and the element content.

Margin defines the space around elements. The margin clears an area around an element (outside the border).

image

Hope that helps!

Thanks Evan

margin is outside space and padding is inside space.

I hope that helps.

https://www.smashingmagazine.com/2009/10/mastering-css-coding-getting-started/#CSS-Basics1

Thanks Jason