CSS padding property
Description of property definition and use
Padding short-case properties set all fill properties in one declaration. The property can have 1 to 4 values.
Instance:
-
padding:10px 5px 15px 20px;
- The upper fill is 10px
- The right fill is 5px
- The underfill is 15px
- The left fill is 20px
-
padding:10px 5px 15px;
- The upper fill is 10px
- The right and left fills are 5px
- The underfill is 15px
-
padding:10px 5px;
- The top and bottom fills are 10px
- The right and left fills are 5px
-
padding:10px;
- All four fills are 10px
Note: Negative values are not allowed.
Default: | 0 |
---|---|
Inherited: | no |
Version: | CSS1 |
JavaScript syntax: | object .style.padding="10px 5px" |
Browser support
The numbers in the table support the first browser version number of the property.
Attributes | |||||
---|---|---|---|---|---|
padding | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
The property value
Value | Description |
---|---|
length | Specify fill values in specific units, such as pixels, centimeters, etc. The default is 0px |
% | Specifies a fill based on a percentage of the width of the parent element |
inherit | Specifies that the pading should be inherited from the parent element |
Related articles
CSS tutorial: CSS Padding