Proprietà paddingRight

Definition and usage

paddingRight Sets or returns the right inner padding of the 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:Margine interno CSS

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";

Try it yourself

Example 2

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

document.getElementById("myDIV").style.paddingRight = "0px";

Try it yourself

Example 3

Returns 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"

Attribute value

Value Description
% Right inner padding is defined as a percentage of the parent element's width.
length Right inner padding is defined 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 representing the right inner padding of an element.
CSS version: CSS1

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supporto Supporto Supporto Supporto Supporto