English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
padding-The top CSS property sets the padding at the top side, that is, the space between the top boundary and the content of an element. However, in many cases, the shorthand notation CSS propertypaddingEasier to use and more desirable.
The following table provides usage instructions and version history of this attribute, as well as its usage syntax 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 |
Can be animated: | Yes.Please refer to Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object.style.paddingTop="2cm" |
The syntax of this attribute is as follows:
padding-top: length | percentage | initial | inherit
The following examples demonstrate how to use padding-top attribute.
h1 { padding-top: 2em; } p { padding-top: 50px; }Test and see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
length | Values in units such as px, pt, cm, em, etc., negative values are not allowed. |
percentage | Specify percentage padding. The percentage is calculated relative to the width of the element's containing block. Negative percentage values are not allowed. |
initial | Set this property to its default value. |
inherit | If specified, the associated element uses its parent element padding-The value of the top attribute. |
padding-Browser compatibility of the top 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 properties:padding,padding-right,padding-bottom,padding-left.