Style paddingRight 属性
- Previous Page paddingLeft
- Next Page paddingTop
- Go Back to Previous Level HTML DOM Style Object
Definition and Usage
paddingRight
Sets or returns the right inner padding of the element.
margin Property and Padding Property They both insert space around the element, but the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See Also:
CSS Tutorial:CSS Internal Padding
CSS Reference Manual:padding-right Property
HTML DOM Reference Manual:Padding Property
Example
Example 1
Set the right inner padding of the <div> element:
document.getElementById("myDIV").style.paddingRight = "50px";
Example 2
Change the right inner padding of the <div> element back to "normal":
document.getElementById("myDIV").style.paddingRight = "0px";
Example 3
Returns the right inner padding of the <div> element:
alert(document.getElementById("myDIV").style.paddingRight);
Example 4
Difference between marginRight and paddingRight:
function changeMargin() { document.getElementById("myDIV").style.marginRight = "200px"; } function changePadding() { document.getElementById("myDIV2").style.paddingRight = "200px"; }
Syntax
Return the paddingRight property:
object.style.paddingRight
Set the paddingRight property:
object.style.paddingRight = "%|length|initial|inherit"
Property Value
Value | Description |
---|---|
% | Define the right inner padding as a percentage of the parent element's width. |
length | Define the right inner padding with length units. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default Value: | 0 |
---|---|
Return Value: | A string that represents the right inner padding of an element. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page paddingLeft
- Next Page paddingTop
- Go Back to Previous Level HTML DOM Style Object