padding-top property
Sets or retrieves the amount of space to insert between the top border of the object and the content.
![]() |
Syntax
padding-top:
<length>
|
<percentage>
Property values
- length
-
Floating-point number, followed by an absolute units designator (
cm,mm,in,pt, orpc) or a relative units designator (em,ex, orpx). For more information about the supported length units, see CSS Values and Units Reference. - percentage
-
Integer, followed by a percent sign (%). The value is a percentage of the width of the parent object.
CSS information
| Applies To | All elements |
|---|---|
| Media | visual |
| Inherited | no |
| Initial Value | 0 |
Standards information
- CSS 2.1, Section 5.5.6
Remarks
As of Microsoft Internet Explorer 5.5, this property applies to inline elements. With earlier versions of Windows Internet Explorer, inline elements must have an absolute position or layout to use this property. Element layout is set by providing a value for the height property or the width property.
Negative values are not allowed.
Examples
The following examples use the padding-top attribute and the padding-top property to change the padding of the object.
This example uses td as a selector in an embedded style sheet to set the top padding for all table cells to 1 centimeter.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/padding-top.htm
<STYLE>
TD { padding-top:1cm }
</STYLE>
This example uses inline scripting to set the cell's top padding to 1 centimeter when an onmouseover event occurs.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/paddingTop.htm
<TD onmouseover="this.style.paddingTop='1cm'"
onmouseout="this.style.paddingTop=''">
<IMG src="sphere.jpg">
</TD>
See also
Send comments about this topic to Microsoft
Build date: 11/29/2012
