CSS Padding
The CSS padding properties are used to generate space around an element’s content, inside of any defined borders.
If the padding
property has four values:
- padding: 25px 50px 75px 100px;
- top padding is 25px
- right padding is 50px
- bottom padding is 75px
- left padding is 100px
CSS Margins
The CSS margin properties are used to create space around elements, outside of any defined borders.
If the margin
property has four values:
- margin: 25px 50px 75px 100px;
- top margin is 25px
- right margin is 50px
- bottom margin is 75px
- left margin is 100px
The padding and margin properties specify top right bottom left.
(If you can’t remember the order, think about the word: TRouBLe)If left is omitted, it will default to right.
Thus, padding: a b c is equivalent to padding: a b c b.If bottom is also omitted, it will default to top.
Thus, padding: a b is equivalent to padding: a b a b.If right is also omitted, the single value is used for all 4 sides.
Thus, padding: a is equivalent to padding: a a a a.