CSS Portal

CSS padding-right Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The padding-right property controls the inner space on the right side of an element between its content and its border. Visually it pushes content inward from the element’s right edge, which changes where text, images, or other child elements appear without altering the position of the element itself in the document flow. Because the padding area is inside the border, background painting and other interior decorations extend into that space, making padding-right a useful tool for adjusting spacing while preserving an element’s visible frame.

This property is often used together with the overall padding shorthand and the opposite edge property padding-left to create balanced interior spacing. Its effect on an element’s final box dimensions depends on the box sizing model in use; for example, the box-sizing mode changes whether padding contributes to the element’s reported width or is included inside it. When adjusting layout, consider how increasing right padding interacts with neighboring elements and available inline space so text wrapping and alignment behave as expected.

For direction-aware layouts, logical properties provide an alternative: instead of targeting the physical right edge you can use padding-inline-end, which maps to the appropriate side for left-to-right and right-to-left content. Also remember the difference between inner and outer spacing: margin sits outside the border and affects spacing between elements, while padding affects spacing inside the element’s border and thus influences background coverage and hit area. Visual and interactive affordances - such as clickable regions or touch targets - are often improved by increasing padding rather than border or margin.

In practice, padding-right behaves consistently across element types but its perceptible effect varies: on block-level boxes it shifts the content box inward horizontally, while on inline-level boxes it contributes to the inline box’s spacing and can affect line wrapping. It does not inherit from parent elements, so explicit values (or shorthands) must be set where needed. Designers and developers commonly animate padding to create smooth spacing transitions or adjust it responsively to control the balance between content and container on different screen sizes.

Definition

Initial value
0
Applies to
All elements
Inherited
No
Computed value
<length> - the percentage as specified or the absolute length
Animatable
Yes
JavaScript syntax
object.style.paddingRight

Interactive Demo

The rusty swing set creaked a lonely lullaby in the twilight, shadows lengthening like grasping fingers across the dew-kissed grass. A lone dandelion seed, adrift on the breeze, whispered secrets of faraway fields, of dandelion suns and galaxies spun from fluff. Somewhere, beyond the veil of dusk, a coyote laughed, echoing through the stillness like a forgotten memory.

Syntax

padding-right: [ <length> | <percentage> ]

Values

  • <length>Specifies a positive fixed width.
  • <percentage>A percentage with respect to the width of the containing block.
  • inherit

Example

  <div class="container">
<h2>Padding-right example</h2>
<div class="box example">This box has <strong>padding-right: 100px</strong> - the extra space appears on the right. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box no-padding">This box has <strong>padding-right: 0</strong> - no extra right padding. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
.container {
  font-family: Arial, sans-serif;
  padding: 20px;
  background: #f7f7f7;
}

.box {
  background: #cce5ff;
  border: 2px solid #2b7bb9;
  margin: 12px 0;
  padding: 12px;
}

.box.example {
  padding-right: 100px;
}

.box.no-padding {
  padding-right: 0;
  background: #ffe0cc;
  border-color: #b86b2b;
}

Browser Support

The following information will show you the current browser support for the CSS padding-right property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!