Easy Tutorial
❮ Css Navbar Css Display Visibility ❯

CSS padding


CSS padding is a shorthand property that defines the space between an element's border and its content, i.e., the padding on all four sides.


padding

When an element's padding is cleared, the released area will be filled with the element's background color.

Using the padding property alone can change the padding on all four sides.

Possible Values

Value Description
length Defines a fixed padding (pixels, pt, em, etc.)
% Uses percentage values to define padding

Padding - Individual Side Padding Properties

In CSS, it can specify different padding for different sides:

Example


Padding - Shorthand Property

To shorten the code, it can specify all the padding properties in one attribute.

This is called a shorthand property. The shorthand property for all padding properties is padding:

Example

padding: 25px 50px;

The padding property can have from one to four values.

padding: 25px 50px 75px 100px;

padding: 25px 50px 75px;

padding: 25px 50px;

padding: 25px;


More Examples

All padding properties in one declaration

Setting left padding

Setting right padding

Setting top padding

Setting bottom padding


All CSS Padding Properties

Property Description
padding Sets all the padding properties in one declaration
padding-bottom Sets the bottom padding of an element
padding-left Sets the left padding of an element
padding-right Sets the right padding of an element
padding-top Sets the top padding of an element
❮ Css Navbar Css Display Visibility ❯