The padding property in CSS defines the innermost portion of the box model, creating space around an element’s content, inside of any defined margins and/or borders.

Padding values are set using lengths or percentages, and cannot accept negative values. The initial, or default, value for all padding properties is 0.

Here’s a simple example:

The example above is using the padding shorthand property, which accepts up to four values, shown here:

If fewer than four values are set, the missing values are assumed based on the ones that are defined. For example, the following two rule sets would get identical results:

Thus, if only one value is defined, this sets all four padding properties to the same value:

If three values are declared, it is padding: [top] [left-and-right] [bottom];

Any of the individual padding properties can be declared using longhand, in which case you would define only one value per property. So the previous example could be rewritten as follows: