CSS padding property

Usage

A shorthand way of setting the padding for all four sides of an element at once.

Variations

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

Values

  • padding-top, padding-right, padding-bottom, and padding-left values

Example

Code:

/* All padding 10px */
p { padding: 10px }

/* Top and bottom 10px, left and right 1em */
p { padding: 10px 1em }

/* Top 10px, left and right 1em, bottom 5% */
p { padding: 10px 1em 5% }

/* Top 10px, right 1em, bottom 5%, left 5px */
p { padding: 10px 1em 5% 5px }