View video tutorial

CSS Padding Shorthand

CSS

We use the shorthand property to shorten the code.

CSS Padding Shorthand

The following properties are used in shorthand padding.

  • padding-top
  • padding-right
  • padding-bottom
  • padding-left

padding: 20px 40px 60px 80px;

Here, top:20px. right:40px. bottom:60px. left:80px.

Example

.p1 {
  padding: 20px 40px 60px 80px;
}
Try it Now »

Click on the "Try it Now" button to see how it works.


padding: 20px 40px 60px;

Here, top:20px. right:40px. bottom:60px. left:40px.

Example

.p1 {
  padding: 20px 40px 60px;
}
Try it Now »

Click on the "Try it Now" button to see how it works.


padding: 20px 40px;

Here, top:20px. right:40px. bottom:20px. left:40px.

Example

.p1 {
  padding: 20px 40px;
}
Try it Now »

Click on the "Try it Now" button to see how it works.


padding: 20px;

Here, top:20px. right:20px. bottom:20px. left:20px.

Example

.p1 {
  padding: 20px;
}
Try it Now »

Click on the "Try it Now" button to see how it works.