With cascading style sheets, any element can have padding. Padding is the space between the edge of an element (its border) and its contents. There can be padding to the left, top, bottom and right of any element. The padding properties are:
What it does
The padding properties set the size of the top, left, bottom, right and all paddings respectively.
Padding can be specified as either a percentage, a length or using the keyword
Padding can not take negative values. If you want to do this, you probably should be using the margin properties.
A percentage padding value sets the affected padding to that percentage of the width of the parent element. For instance, a
padding-right: 20% sets the width of the right padding to 20% of the width of the element which contains the element. This is true even for
We cover length values in detail in our section on values. Essentially though there are two types of length value. There are absolute values such as px. If you use one of these, the actual length of the padding will always be the same. You design much more flexible pages if you use a relative value, like em. If you use a relative value the size of the padding will always be proportional to the calculated size of the content of the element. This is to be encouraged.
If no padding value is specified, the padding of an element is 0. That is, there is no space between the edge of an element and the contents of the element.
Is it inherited?
An element does not inherit the padding property of the element which contains it.