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 trialOsama Mansour
1,411 Pointswhat is the function of margin and padding in web designing?
margin and padding
2 Answers
Paul Allison
2,468 Pointsmargin and padding give you control over the space inside and around your element...... between its content and border is padding ............and outside its border the margin.
you could use them to separate links or images inside an element .....PADDING
or to separate different elements on your page from each other .....MARGIN
http://www.w3schools.com/css/css_padding.asp
http://www.w3schools.com/css/css_margin.asp
copy and paste these links .
Mark Wilkowske
Courses Plus Student 18,131 PointsAdding on to Paul's answer, if you have not heard about the Box Model then that will help understand margin & padding too. The CSS you write fits around HTML elements in a certain way - like a box.
Examples I use - for <p> I put 15px bottom margin on <p>'s because usually another <p> will follow and so that margin creates nice horizontal space between <p>s. For padding, if I have <li><a>home</a></li> I'll put padding on <a> if I want the link to appear like a button.
You can test margin/padding out here http://getbootstrap.com/css/ and in Firebug inspect .nav navbar-nav <li><a></a><li>
david Ramirez
Courses Plus Student 2,798 Pointsdavid Ramirez
Courses Plus Student 2,798 PointsThe function of the padding it generates space. For the margin it also generates space around elements.