Openwave Mobile Browser 7.0: XHTML Mobile Profile and CSS Reference

Section 23 out of 38 total sections
Current chapter: CSS Reference

Padding Properties

You can use the padding properties to add space between an element's content and its border. The color or image displayed in the padding region is the same as that of the background. Elements have no padding unless you set it with the padding properties or they inherit padding from a parent element.

Padding is described in The CSS Box Model.



padding-top, padding-right, padding-bottom, padding-left

Sets the distance between content and its top, right, bottom, or left border.

Values

em, ex, cm, mm, in, pt, pc, px, %, auto, inherit

For more information, see Units of Measure, Percentage, and Keywords.

Default Value

0

Useful For

Block elements and replaced inline elements (such as <img> and <object>).

Inherited

No.

Notes

Percentage values are relative to the width of the containing block.

Example
h1 {padding-top: 2px}

Adds 2 pixels of space between the text of a first-level head and its border.



padding

A shorthand property for setting the width of padding: all at once, in sets, or individually, as described in The CSS Box Model.

Values

em, ex, cm, mm, in, pt, pc, px, %, auto, inherit

For more information, see Units of Measure, Percentage, and Keywords.

Default Value

None.

Useful For

Block elements and replaced inline elements (such as <img> and <object>).

Inherited

No.

Notes

Percentage values are relative to the width of the containing block.

Example
img.pad {padding: 5px}

Adds 5 pixels of space between an image whose class="pad" and the border of that image.