Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS scroll-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 scroll-padding-right property controls how far inward from the right edge of a scroll container the browser treats the "safe" or "snapping" area when performing scroll alignment and snap calculations. Rather than changing box geometry or visual padding, it shifts the effective scrollport used for aligning content: targets that are scrolled or snapped into view will be positioned relative to that inset instead of flush against the physical right edge. This makes the property useful when you want a scrolled-to element to stop short of the container edge so it remains visible behind overlays, controls, or other UI elements.

In practice, scroll-padding-right affects the outcome of scroll-snapping and programmatic scrolling operations. When combined with scroll-snap-type, it alters the positions the browser considers valid snap destinations for child elements, effectively moving snap points inward from the right. It also interacts with scripted or user-initiated scrolls (for example, when calling methods that align an element into view), and will change where the element lands without changing its layout. For smooth or animated scrolls, this inward offset determines the final resting position the animation aims for, and it works alongside behavior controls such as scroll-behavior.

Because scroll-padding-right is a physical, right-side property, its meaning can differ when writing mode or direction changes; for writing-mode–independent adjustments you can use the logical equivalent scroll-padding-inline-end. It is distinct from regular box padding - the latter affects layout, background, and hit testing, whereas scroll padding only influences scroll alignment and snapping calculations. Choose the physical form when you specifically need to target the right side regardless of text direction, and the logical form when you want consistent behavior across different writing modes.

Common use cases include leaving space for fixed or sticky UI elements (so focused or snapped items aren't hidden), fine-tuning per-side snap offsets in complex scroll containers, and improving the perceived layout during programmatic scrolling. Keep in mind that the property applies to the scroll container itself; child elements are aligned according to the container’s computed scroll padding, and it does not create extra visual space or alter the position of static layout elements outside of scroll alignment behavior.

Definition

Initial value
auto
Applies to
scroll containers
Inherited
no
Computed value
as specified
Animatable
by computed value type
JavaScript syntax
object.style.scrollPaddingRight

Interactive Demo

1
2
3
Scroll »

Syntax

scroll-padding-right: auto | <length-percentage [0,∞]>>

Values

  • autoThe offset is determined by the user agent. This will generally be 0px, but the user agent is free to detect and do something else if a non-zero value is more appropriate.
  • <length-percentage>An inwards offset from the corresponding edge of the scrollport, as a valid <length> or a <percentage>.

Example

<div class="example">
<h2>Scroll Padding Right Demo</h2>
<div class="viewport" tabindex="0">
<div class="card">1</div>
<div class="card">2</div>
<div class="card">3</div>
<div class="card">4</div>
<div class="card">5</div>
<div class="card">6</div>
<div class="card">7</div>
</div>
<p class="hint">Scroll horizontally and observe extra space at right edge due to scroll-padding-right.</p>
</div>
/* Layout and reset */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  padding: 2rem;
  background: #f7f7f7;
  color: #111;
}

.example {
  max-width: 800px;
  margin: 0 auto;
}

/* Scroll container */
.viewport {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem;
  background: #ffffff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  scroll-snap-type: x mandatory; /* enable snapping */
  scroll-padding-right: 4rem;    /* <--- important: creates extra padding on the right when snapping */
  -webkit-overflow-scrolling: touch;
}

/* Items */
.card {
  flex: 0 0 220px;
  height: 140px;
  background: linear-gradient(135deg, #6dd3ff, #8b5cf6);
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  scroll-snap-align: start;
}

.hint {
  margin-top: 0.75rem;
  color: #666;
  font-size: 0.95rem;
}

Browser Support

The following information will show you the current browser support for the CSS scroll-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!