0 Comments
Padding is used to clear the area around the content of an element within the border and is affected by the background color of the element.
While, margin clear the area around an element which is outside the border and do not have a background color.
See at an example of a box model:
Now let’s have an explanation how these are used to style and customize the CSS and Blogger templates, taking margins as an example. We see in the picture that margins have been used to clear the area around the box. So (let) the CSS styling properties used are:
box {
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 10px;
}
We can also write this as:
box {This is because we are using 10 pixels for all the sides of the margin.
margin: 10px;
}
box {We can write this also as:
margin-top: 5px;
margin-right: 10px;
margin-bottom: 7px;
margin-left: 8px;
}
box {Notice the order of the values used. First comes the top margin, then the right margin, the bottom and then the left.
margin: 5px 10px 7px 8px;
}
Let’s see another example:
box {Notice that the top and the bottom margin have same values while the left and the right are same.
margin-top: 10px;
margin-right: 5px;
margin-bottom: 10px;
margin-left: 5px;
}
So:
box {The same thing happens when it comes to use the padding properties within CSS. Thus we got a general idea about how the margins and paddings are used to style CSS and Blogger templates.
margin: 10px 5px;
}
For more references: W3 school CSS margin and W3 school CSS padding