CSS padding-right Property

CSS padding-right property defines the padding for the right side of an element. The padding-right is the space between the content and the right border of an element.

The padding-right property can be specified in any valid CSS length formats such as ‘px’, ’em’, ‘rem’, ‘cm’, etc. It can also be specified using percentage(%). It does not accept negative values.

Example:

.p1{
  padding-right: 40px;
}
.p2{
  padding-right: 4em;
}
.p3{
  padding-right: 20%;
}

CSS Syntax

The padding-right property has the following syntax:

padding-right: length|percentage|initial|inherit;

Property Values

The padding-right property accepts the following values:

lengthSets a fixed right padding in CSS length formats such as ‘px’, ’em’, ‘rem’, ‘cm’, etc. The default value is zero.
percentageSets right padding in percentage. The percentage value is calculated by taking the percentage of the element’s width itself.
initialSets the padding-right property to its default value(0).
inheritInherits the padding-right property from the parent element.

General Info

Default Value0
InheritedNo
JavaScript Usageelement.style.paddingRight = “40px”