CSS padding
CSS padding is a shorthand property that defines the space between an element's border and its content, i.e., the top, bottom, left, and right inner margins.
padding
When an element's padding is cleared, the freed area will be filled with the element's background color.
Using the padding property individually can change the top, bottom, left, and right padding.

Possible values
| Value | Description |
|---|---|
| length | Define a fixed padding (pixels, pt, em, etc.) |
| % | Define a padding using a percentage value |
Padding - individual side padding properties
In CSS, it can specify different padding for different sides:
Example
padding-top:25px;
padding-bottom:25px;
padding-right:50px;
padding-left:50px;
Try it »
- Top padding is 25px
- Right padding is 50px
- Bottom padding is 25px
- Left padding is 50px
Padding - shorthand property
To shorten the code, it can specify all padding properties in a single property.
This is called a shorthand property. The shorthand property for all padding properties is padding:
Example
padding:25px 50px;
Try it »
The padding property can have one to four values.
** padding:25px 50px 75px 100px;**
- Top padding of 25px
- Right padding of 50px
- Bottom padding of 75px
- Left padding of 100px
** padding:25px 50px 75px;**
- Top padding of 25px
- Left and right padding of 50px
- Bottom padding of 75px
** padding:25px 50px;**
- Top and bottom padding of 25px
- Left and right padding of 50px
** padding:25px;**
- All padding is 25px
More examples
All padding properties in a single declaration
This example demonstrates setting all padding properties in a single declaration using the shorthand property, which can have one to four values.
Set the left padding
This example demonstrates how to set the left padding of an element.
Set the right padding
This example demonstrates how to set the right padding of an element..
Set the top padding
This example demonstrates how to set the top padding of an element.
Set the bottom padding
This example demonstrates how to set the bottom padding of an element.
All CSS padding properties
| property | Description |
|---|---|
| padding | Shorthand property that sets all padding properties in a single declaration |
| padding-bottom | Set the bottom padding of an element |
| padding-left | Set the left padding of an element |
| padding-right | Set the right padding of an element |
| padding-top | Sets the top padding of an element. |