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
nooby
2,716 Pointscss
what is the difference between margin ,padding and width and in what sense?
1 Answer
Lachlan ∆
8,026 PointsPadding 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 :)
Liam Maclachlan
22,805 PointsLiam Maclachlan
22,805 PointsJust to build on the answer, here is quite a good resource, too :) http://www.w3schools.com/css/css_boxmodel.asp