XML technologies / CSS / Advanced websites with CSS / CSS property reference / padding-bottom, padding-top, padding-left, padding-right

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

The properties padding-bottom, padding-top, padding-left and padding-right describe the size of an element’s bottom, top, left and right padding.

Padding is the area between an element’s content and border. Any background colour or image also fills the padding area.

Inherited: no

See also: padding

Values

Each value may be a CSS measurement or a percentage of the parent element’s width or height.

Default value: 0

Compatibility

CSS version: 1

Works in all CSS-capable browsers, including Internet Explorer 4 and Netscape 4.

For elements with a border, Netscape 4 leaves a three-pixel gap between the border and padding. This gap cannot be removed and remains transparent even when the element has a background. Netscape’s proprietary properties layer-background-color and layer-background-image can fill this gap separately with the background colour or image.

Example

The following rule creates a thin border and red background for elements of the class warnung. To create some whitespace inside, it also adds five pixels of padding at the top and bottom and ten pixels at the left and right:

.warnung {
 border: 1px solid;
 background-color: red;
 padding-top: 5px;
 padding-bottom: 5px;
 padding-left: 10px;
 padding-right: 10px;
}

  

 

 

 

back to top