Style paddingRight egenskab
- Forrige side paddingLeft
- Næste side paddingTop
- Gå tilbage til forrige niveau HTML DOM Style Object
Definition and usage
paddingRight
Sets or returns the right inner padding of an element.
margin property and padding property They all insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See also:
CSS Tutorial:CSS indre kant
CSS Reference Manual:padding-right property
HTML DOM Reference Manual:padding property
Instance
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
Return 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 a length unit. |
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 supports
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Støtte | Støtte | Støtte | Støtte | Støtte |
- Forrige side paddingLeft
- Næste side paddingTop
- Gå tilbage til forrige niveau HTML DOM Style Object