English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The CSS padding property can set padding on all four sides of an element. It ispadding-top,padding-right,padding-bottomandpadding-leftAbbreviated property of the attribute.
The table below provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.
Default Value: | 0 |
---|---|
Applies to: | All elements, except<tbody>,<thead>,<tfoot>,<tr>,<colgroup>and<col>. It also applies to::first-letter. |
Inheritance: | No |
Animatable: | Yes.Please refer to Animation Attributes. |
Version: | CSS 1,2,3 |
JavaScript Syntax: | object.style.padding="20px 15px" |
The syntax of this attribute is as follows:
padding: [ length | percentage] 1 to 4 values | initial | inherit
The following example demonstrates how to use the padding attribute.
p.one { padding: 20px; } p.two { padding: 35px 15px; }Test and see‹/›
This shorthand notation can take one, two, three, or four space-separated values.
if seta valuethen this padding applies to all4a face.
If setTwo valuesIf the first value is applied to the top and bottom, and the second value is applied to the right and left.
Three values respectivelyApplied to the top, horizontal (i.e., left and right), and bottom.
Four valuesApplied sequentially to the top, right, bottom, and left.
The following table describes the value of this attribute.
Value | Description |
---|---|
padding-top | Set the padding to the top side of the element. |
padding-right | Set the padding to the right side of the element. |
padding-bottom | Set the padding to the bottom side of the element. |
padding-left | Set the padding to the left side of the element. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts the padding attribute value of its parent element. |
Browser Compatibility of padding Attribute, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.
|
See the following tutorials:CSS Padding,CSS Box Model.
Related Attributes:padding-top,padding-right,padding-bottom,padding-left.