Padding

Learn how padding works in CSS.

The padding property

The padding property is conceptually similar to the margin property, with a few slight differences. The padding defines the inner portion of the box model. It creates space around the content of an element, within any margins and borders. We specify our element’s padding at each side, like so:

padding-top: 10px:
padding-right: 20px;
padding-bottom: 10px
padding-left: 20px;

Padding shorthand

We can use the padding shorthand in the same manner as the margin shorthand:

padding: 10px 20px 30px 0px;

Just like with margins, padding values can also be px, em, rem, percentages, or any other CSS unit value.

Example

Get hands-on with 1400+ tech skills courses.