Padding is used to give space inside certain elements, while margin is to give space between different elements. Padding also has a shorthand property for specifying the padding for each side of an element.
1) Four properties – padding: 25px 50px 75px 100px;
– Top padding is 25px
– Right padding is 50px
– Bottom padding is 75px
– Left padding 100px.
2) Three properties – padding 25px 50px 75px;
– Top padding is 25px
– Right and left padding are 50px
– Bottom padding is 75px
3) Two properties – padding 25px 50px;
– Top and bottom padding are 25px
– Right and left padding are 50px
One more thing, if there are two conflicting margins, then the margin that’s bigger would be the one prioritized to get rendered on a website. This phenomenon is referred to as “Collapsing Margins”. If there are two margins with the same value, then it wouldn’t matter which one is used over the other as both will have the same result of rendering.
