CSS padding-top property
Example
Set the top padding of a p element:
p
{
padding-top:
2
cm
;
}
Try it »
Property definition and usage
The padding-top property sets the top padding (space) of an element.
Note: Negative values are not allowed.
| Default value: | 0 |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object.style.paddingTop="2cm" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| padding-bottom | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Attribute values
| Value | Description |
|---|---|
| length | Specifies a fixed top padding in a specific unit, such as pixels, centimeters, etc. The default value is 0px. |
| % | Defines a top padding as a percentage of the parent element's width. This value may not work as expected in all browsers. |
| inherit | Specifies that the top padding should be inherited from the parent element. |
Related Articles
CSS Tutorial: CSS Padding