Back to CSS1 Reference | CSS1 Properties
Prev margin-top | Next padding-bottom


Property
padding
Values
<length>, <percentage>
Initial
not defined for shorthand properties
Inherited
no

The 'padding' property is a shorthand property for setting 'padding-top', 'padding-right', 'padding-bottom' and 'padding-left' at the same place in the style sheet.

If four values are specified they apply to top, right, bottom and left respectively. If there is only one value, it applies to all sides, if there are two or three, the missing values are taken from the opposite side.

The surface of the padding area is set with the 'background' property:

      H1 { 
      background: white; 
      padding: 1em 2em;
      } 

The example above sets a '1em' padding vertically ('padding-top' and 'padding-bottom') and a '2em' padding horizontally ('padding-right' and 'padding-left'). The 'em' unit is relative to the element's font size: '1em' is equal to the size of the font in use.

Padding values cannot be negative.