Both padding and margins are used to create space.
Padding creates space within the element and margins create space between elements.
this is an example of an element without padding
[css].text-box-1{
border: 2px solid #000;
width:300px;
}[/css]
Let’s see the same box with padding applied to the sides, top and bottom.
[css].text-box-2{
border: 2px solid #000;
width:300px;
padding: 10px 15px 10px 15px;
}[/css]
If we had two of these boxes together without margins it would look like this.
To fix this problem we add a margin in this case we’ll add 10px to the top and bottom
[css].text-box-3{
border: 2px solid #000;
width:300px;
padding: 10px 15px;
margin: 10px 0 10px 0;
}[/css]
Padding and margins work on a clock system
the first number is 12 or the top
the second number is 3 or the right
the third number is 6 or the bottom
the fourth number is 9 or the left
Debra
Owner Fat Cat Designs
I am a freelancer in the Hamilton, Ont. area. I have been working with WordPress since 2004. First developing for myself and eventually for others. I discovered I have a love for code especially CSS. I am a strong supporter of social justice and human rights and enjoy working on blogs that reflect those values.