Extensible HyperText Markup Language

XHTML.com recommends: PSD to HTML Slicing Service

padding

Definition

The padding property is a shorthand method of setting padding-top, padding-right, padding-bottom and/or padding-left. Padding is the space between the element's content and the element's border, represented by the yellow highlighted area in the illustration below.

Illustration of the CSS box model. The area between content and border is highlighted in yellow.

Example

  1. p {padding: 2em}
  2. p {padding: 2em 1em}

Characteristics

Possible values

  • One, two, three or four of the following values: a specific length, a percentage of the parent element's width or the keyword auto. If there is only one value, it applies to all sides. If there are two values, the first value is applied to the top and bottom sides, and the second value is applied to the right and left sides. If there are three values, the first value is applied to the top side, the second value is applied to the right and left sides, and the third value is applied to the bottom side. If there are four values, the first value is applied to the top side, the second value is applied to the right side, the third value is applied to the bottom side and the forth value is applied to the left side.
  • inherit
    Use the same computed value as the parent element for this property.

Default value

See individual properties

Applies to

Most elements

Inherited

No

See also