0
css padding and margin
When we need to use padding and when we need to use margin?
2 Answers
+ 8
Padding is the space inside the box, margin is the space outside the box.
create a border and/or background-color and use padding, then margin on your element and you'll see the difference.
+ 2
They have some differences:
* Margin is outer space of an element, while Padding is inner space of an element.
* Margin is the space outside the border of an element, while Padding is the space that is inside the border of it.
* Margin can be valued auto: margin: auto, but you can't give Padding the value of auto.
* Margin can provide value of positive or negative (or zero), otherwise, Padding must be positive (or zero).
* In navigation bars or anchors (links) and other tags, Padding is a part of the element that accepts changes. When you style an element, changes not happens to Margin, but the space that Padding has created will be change.
Tip: You can see these differences on some tags that you use to control other tags; like div and span, or section and article. Also is good to see changes in navigation bars.