Table of Contents

CSS - Padding

About

The padding area is the space between the content of the box and its border.

In the below image, this are the areas:

Css Padding

This area is a part of the background.

Example

2 lengths / 2 axis

p { 
    padding: 10px 20px; 
    /* same than 
    padding-top:10px; 
    padding-bottom:10px; 
    padding-right:20px; 
    padding-left:20px; 
    */
}
p {
    background-color: skyblue; 
    border: 1px solid
}
<p>Lorem Ipsum</p>

3 lengths / 1 side - 1 axis - 1 side

p {
    padding: 10px 20px 30px; 
    /* same as
    padding-top: 10px;
    padding-right: 20px;
    padding-left: 20px;
    padding-bottom: 30px;
    */
    background-color: skyblue; 
    border: 1px solid 
}
<p>Lorem Ipsum</p>

4 lengths / 4 sides

p { 
    padding: 10px 20px 30px 40px;
    background-color: skyblue; 
    border: 1px solid 
}
<p>Lorem Ipsum</p>

Usage

Syntax

This area is set:

padding properties cannot utilize negative length, margin can