padding-right property
Sets or retrieves the amount of space to insert between the right border of the object and the content.
![]() |
Syntax
padding-right:
<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.7
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-right attribute and the padding-right property to change the padding of the object.
This example uses td as a selector in an embedded style sheet to set the right padding for all table cells to 1 centimeter.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/padding-right.htm
<STYLE>
TD { padding-right:1cm }
</STYLE>
This example uses inline scripting to set the cell's right padding to 1 centimeter when an onmouseover event occurs.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/paddingRight.htm
<TD onmouseover="this.style.paddingRight='1cm'"
onmouseout="this.style.paddingRight=''">
<IMG src="sphere.jpg">
</TD>
See also
- CSSStyleDeclaration
- currentStyle
- defaults
- runtimeStyle
- style
- CSS Enhancements in Internet Explorer 6
Send comments about this topic to Microsoft
Build date: 11/29/2012

