CSS padding properties
Attribute definitions and instructions
padding shorthand property to set all fill attributes in a statement. This property can have the value 1-4.
Example:
- padding: 10px 5px 15px 20px;
- The padding is 10px
- Right padding is 5px
- By padding is 15px
- Left padding is 20px
- padding: 10px 5px 15px;
- The padding is 10px
- Left and right padding is padding 5px
- By padding is 15px
- padding: 10px 5px;
- Upper and lower padding is 10px padding
- Left and right padding is padding 5px
- padding: 10px;
- All four are 10px padding
Note: negative values are not allowed.
Defaults: | 0 |
---|---|
inherit: | no |
version: | CSS1 |
JavaScript syntax: | object .style.padding = "10px 5px" |
Browser Support
Figures in the table represent the first browser to support the version number of the property.
属性 | |||||
---|---|---|---|---|---|
padding | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Property Value
value | Explanation |
---|---|
length | Filling a predetermined value in terms of specific units, such as pixels, centimeters, and the like. The default value is 0px |
% | Provision based on a percentage of the parent element width filling |
inherit | Specifies the padding should be inherited from the parent element |
related articles
CSS tutorial: CSS the Padding