Style paddingRight Property

定义和用法

paddingRight Definition and Usage

paddingRight Sets or returns the right inner padding of the element. padding-right property margin property

and

All insert spaces around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.CSS Internal Padding

See Also:CSS Tutorial:

CSS Reference Manual:padding-right property

HTML DOM Reference Manual:

padding property

Instance

Example 1

Try It Yourself

Set the right inner padding of the <div> element:

Example 2

Reset the right inner padding of the <div> element to "normal":

Try It Yourself

Example 3

Return the right inner padding of the <div> element:

alert(document.getElementById("myDIV").style.paddingRight);

Try It Yourself

Example 4

Difference between marginRight and paddingRight:

function changeMargin() {
  document.getElementById("myDIV").style.marginRight = "200px";
}
function changePadding() {
  document.getElementById("myDIV2").style.paddingRight = "200px";
}

Try It Yourself

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 Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support