Name
padding — IE4 P/P | IE5 P/Y | NN4 B/B | Op3 B/-
Synopsis
This sets the size of the overall padding of an element. The padding will “inherit” the element’s background; in other words, the background of an element fills its content area and padding. Padding set on inline elements does not affect line-height calculations, but will be applied to the right and left ends of the element. If an inline element has both padding and a background, the background may be extended above and below the edges of the line-box in which the inline element appears, but user agents are not required to support this behavior. There is also no defined behavior to say whether the foreground content of a previous line appears above the background of a succeeding line, or is overwritten by that background. Negative values are not permitted.
Example
H1 {padding: 2ex;}
Values
[ <length> | <percentage> ]{1,4}
Default
not defined for shorthand properties
Inherited
no
Applies to
all elements
Percentage values refer to the width of closest block-level ancestor.
Get Cascading Style Sheets: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.