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

HTML How to Make a Website CSS: Cascading Style Sheets Take a Mobile-First Approach

can someone tell me what is the different between padding and margin on css?

i'm confused

If you think of elements on a page as 'boxes' , padding adds space within the element's 'box' and margin adds space on the outside of the element's 'box'.

2 Answers

A brief description:

Padding is for putting space around elements.

Margin is for moving elements.

I hope you understand now :)

Tomasz Halaczkiewicz
Tomasz Halaczkiewicz
21,845 Points

Padding is a space added inside of an element, margin is a space outside of an element that seperates the element from other elements.