Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Osama 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
Treehouse Moderator 17,494 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,797 Pointsdavid Ramirez
Courses Plus Student 2,797 PointsThe function of the padding it generates space. For the margin it also generates space around elements.