HTML CSS examples for CSS Property:padding-top
The padding-top CSS property sets the padding to the top side.
Padding is the amount of space between the top border and the content of an element.
The following table summarizes the padding-top Property.
Item | Value |
---|---|
Default value: | 0 |
Applies to: | All elements except <tbody>, <thead>, <tfoot>, <tr>, <colgroup> and <col>. It also applies to ::first-letter. |
Inherited: | No |
Animatable: | Yes. |
The syntax of the property is as follows:
padding-top: length | percentage | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
length | Set the padding as a length value in px, pt, cm, em, etc. Negative length values are not allowed. |
percentage | Set the padding in percentage which is calculated with respect to the width of the element's containing block. Negative percentage values are not allowed. |
initial | Sets this property to its default value. |
inherit | take the value of its parent element padding-top property. |
The example below shows the padding-top property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS padding-top property</title> <style type="text/css"> h1 {<!--from w w w . j av a2 s . c o m--> padding-top: 2em; background: #ffb6c1; } p { padding-top: 50px; background: #f0e68c; } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>