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

css

what is the difference between margin ,padding and width and in what sense?

1 Answer

Padding adds space inside the element. For example if you set the h1 padding to 5px it would have a 5px space all around the text.

Margin adds space outside the element. So adding 15px to the right margin would push other elements 15px away from the right side or position the element 15px left because it's being pushed from the right.

Width sets the width of the element. For example if the width of a button was 30px, it would be a total of 30px wide.

I hope this helped and goodluck :)

Just to build on the answer, here is quite a good resource, too :) http://www.w3schools.com/css/css_boxmodel.asp