CSS scroll-padding-right Property

The CSS scroll-padding-right property defines an inset from the physical right edge of a scroll container's scrollport for scroll alignment.

This property adjusts the optimal viewing region used for scroll snapping and other scrolling operations. It is useful when content should align away from the right edge, particularly in horizontal carousels, scrolling navigation, and interfaces with overlapping controls.

scroll-padding-right Syntax

The scroll-padding-right property accepts one non-negative CSS length, percentage, or the auto keyword.

Basic Syntax

selector {
  scroll-padding-right: 40px;
}

Available Values

.container {
  scroll-padding-right: 0;
}
.container {
  scroll-padding-right: 20px;
}
.container {
  scroll-padding-right: 3rem;
}
.container {
  scroll-padding-right: 1.5em;
}
.container {
  scroll-padding-right: 10%;
}
.container {
  scroll-padding-right: auto;
}
.container {
  scroll-padding-right: calc(2rem + 10px);
}

CSS-Wide Keywords

.container {
  scroll-padding-right: initial;
}
.container {
  scroll-padding-right: inherit;
}
.container {
  scroll-padding-right: unset;
}
.container {
  scroll-padding-right: revert;
}
.container {
  scroll-padding-right: revert-layer;
}

Negative values are invalid. The property accepts only one value because it controls a single physical edge.

Property Values

Value Description
<length> Sets a non-negative right inset using a CSS length such as px, rem, or em.
<percentage> Sets the right inset relative to the scrollport's width.
auto Allows the browser to determine an appropriate inset, typically zero.
0 Specifies no additional right scroll padding.
calc() Calculates a non-negative length or percentage-based inset.
initial Resets the property to its initial value of auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Scroll containers
Computed value As specified
Animation type By computed value type
Percentages Relative to the scrollport's width
Negative values Not accepted
Physical edge Right
Shorthand scroll-padding

Valid Values

.container {
  scroll-padding-right: 50px;
}
.container {
  scroll-padding-right: 15%;
}
.container {
  scroll-padding-right: 4rem;
}
.container {
  scroll-padding-right: auto;
}
.container {
  scroll-padding-right: calc(2rem + 12px);
}

Invalid Values

.container {
  scroll-padding-right: -20px;
}
.container {
  scroll-padding-right: 10px 20px;
}
.container {
  scroll-padding-right: smooth;
}
.container {
  scroll-padding-right: normal;
}
.container {
  scroll-padding-right: 2s;
}

Negative lengths, multiple values, unrelated keywords, and time units are invalid.

How It Works

The scroll-padding-right property establishes an inset from the physical right edge of the scrollport. This adjusts the optimal viewing region used when aligning scroll targets.

For right-aligned scroll targets, the browser can position content inward from the right edge instead of directly against the scrollport boundary.

Default Right Scroll Padding

.container {
  scroll-padding-right: auto;
}

The browser determines the inset. In most cases, the effective value is zero.

Fixed Right Inset

.container {
  scroll-padding-right: 60px;
}

The optimal viewing region ends 60 pixels inward from the physical right edge.

Percentage-Based Inset

.container {
  scroll-padding-right: 10%;
}

The inset is calculated as 10% of the scrollport's width. For example, a 400-pixel-wide scrollport produces a 40-pixel inset.

Relative Lengths

.container {
  scroll-padding-right: 3rem;
}

Relative units allow the inset to scale with font-size settings.

No Layout Changes

Scroll padding does not add physical space to the container or move its child elements. Unlike padding-right, it affects scroll alignment rather than normal layout.

Available Scroll Range

The browser may not achieve the requested alignment if the scroll container does not have enough available scroll range.

Using scroll-padding-right With Scroll Snap

The scroll-padding-right property is useful when scroll snap targets should align inward from the physical right edge.

Horizontal Scroll Snap

.scroll-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-right: 50px;
}
.scroll-container .item {
  flex: 0 0 220px;
  scroll-snap-align: end;
}

In left-to-right horizontal writing, items can snap 50 pixels inward from the right edge instead of aligning directly against it.

Different Left and Right Insets

.scroll-container {
  scroll-padding-left: 20px;
  scroll-padding-right: 60px;
}

The optimal viewing region begins 20 pixels inward from the left edge and ends 60 pixels before the right edge.

End Alignment

.scroll-container {
  scroll-padding-right: 40px;
}
.scroll-container .item {
  scroll-snap-align: end;
}

In left-to-right horizontal writing, end-aligned items can snap inward from the right edge.

Combining Scroll Padding and Scroll Margin

.scroll-container {
  scroll-padding-right: 40px;
}
.scroll-container .featured {
  scroll-margin-right: 20px;
  scroll-snap-align: end;
}

For left-to-right horizontal end alignment, these values can produce a combined 60-pixel offset between the featured item's right border edge and the scrollport's right edge.

Important Consideration

Scroll padding does not enable snapping by itself. The container requires scroll-snap-type, and targets require scroll-snap-align.

Horizontal Carousels

Horizontal carousels often need alignment spacing at the right edge of the scrolling area. The scroll-padding-right property can provide that spacing without changing normal layout.

Basic Carousel

.carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-right: 40px;
}
.carousel .slide {
  flex: 0 0 250px;
  scroll-snap-align: end;
}

In left-to-right horizontal writing, slides can snap inward from the right edge, leaving a 40-pixel alignment inset.

Adding Layout Space at the Right Edge

.carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-right: 40px;
  scroll-padding-right: 40px;
  scroll-snap-type: x mandatory;
}

Layout padding creates actual space after the carousel content, while scroll padding establishes the intended alignment inset. Using both can help the final slide align consistently.

Responsive Right Insets

.carousel {
  scroll-padding-right: 16px;
}
@media (min-width: 768px) {
  .carousel {
    scroll-padding-right: 48px;
  }
}

The carousel uses a smaller right alignment inset on narrow screens and a larger inset on wider screens.

Right-to-Left Carousels

.carousel {
  direction: rtl;
  scroll-padding-right: 40px;
}

The inset remains on the physical right edge. In right-to-left horizontal writing, this corresponds to inline-start rather than inline-end.

Important Consideration

Scroll padding does not guarantee additional scroll range at the right edge of a carousel. Layout padding or another spacing technique may be necessary to achieve the desired alignment for edge items.

Programmatic Scrolling

JavaScript scrolling methods can use the optimal viewing region established by scroll-padding-right when aligning a target.

Using scrollIntoView()

.scroll-container {
  scroll-padding-right: 60px;
}
document.querySelector(".target").scrollIntoView({
  behavior: "smooth",
  inline: "end",
  block: "nearest"
});

In left-to-right horizontal writing, the target can align approximately 60 pixels inward from the right edge, provided sufficient scroll range is available.

Using Nearest Alignment

document.querySelector(".target").scrollIntoView({
  behavior: "smooth",
  inline: "nearest",
  block: "nearest"
});

Nearest alignment minimizes scrolling rather than forcing end alignment, so the resulting position may differ.

Respecting Reduced Motion

const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
document.querySelector(".target").scrollIntoView({
  behavior: reduceMotion ? "instant" : "smooth",
  inline: "end",
  block: "nearest"
});

Consider reduced-motion preferences when using animated scrolling.

Important Consideration

The inline option uses logical alignment. In right-to-left horizontal writing, inline: "end" aligns toward the physical left edge, while scroll-padding-right continues to affect the physical right edge. Use inline: "start" to align toward the right edge in that writing direction.

Using the scroll-padding Shorthand

The scroll-padding shorthand sets scroll padding for all four physical edges of a scroll container.

One Value

.container {
  scroll-padding: 30px;
}

All four edges receive 30 pixels.

Two Values

.container {
  scroll-padding: 20px 60px;
}

The top and bottom edges receive 20 pixels, while the left and right edges receive 60 pixels.

Three Values

.container {
  scroll-padding: 10px 20px 30px;
}

Top receives 10 pixels, left and right receive 20 pixels, and bottom receives 30 pixels.

Four Values

.container {
  scroll-padding: 10px 20px 30px 40px;
}

The values apply clockwise: top 10 pixels, right 20 pixels, bottom 30 pixels, and left 40 pixels.

Equivalent Longhand Declarations

.container {
  scroll-padding-top: 10px;
  scroll-padding-right: 20px;
  scroll-padding-bottom: 30px;
  scroll-padding-left: 40px;
}

Overriding the Right Edge

.container {
  scroll-padding: 20px;
  scroll-padding-right: 60px;
}

The right inset becomes 60 pixels, while the other three edges remain at 20 pixels.

Declaration Order

.container {
  scroll-padding-right: 60px;
  scroll-padding: 20px;
}

The later shorthand resets the right inset to 20 pixels along with the other three edges.

Logical Versus Physical Scroll Padding

Physical scroll padding always refers to fixed edges. Logical scroll padding follows the writing mode and text direction.

Property Edge
scroll-padding-right Physical right
scroll-padding-left Physical left
scroll-padding-top Physical top
scroll-padding-bottom Physical bottom
scroll-padding-inline-start Logical inline-start
scroll-padding-inline-end Logical inline-end
scroll-padding-block-start Logical block-start
scroll-padding-block-end Logical block-end

Physical Right Inset

.container {
  scroll-padding-right: 50px;
}

The inset always applies to the physical right edge, regardless of writing mode or direction.

Logical Inline-End Inset

.container {
  scroll-padding-inline-end: 50px;
}

The inset applies to the right edge in left-to-right horizontal writing, but to the left edge in right-to-left horizontal writing.

Physical Edge Mapping

Writing Mode Direction Logical Equivalent of Right
horizontal-tb ltr inline-end
horizontal-tb rtl inline-start
vertical-rl ltr or rtl block-start
vertical-lr ltr or rtl block-end

Overlapping Declarations

.container {
  direction: ltr;
  scroll-padding-right: 20px;
  scroll-padding-inline-end: 60px;
}

In left-to-right horizontal writing, both declarations affect the right edge. With equal specificity and importance, the later declaration takes precedence.

Choosing the Appropriate Property

Use scroll-padding-right when the inset must remain on the physical right edge. Use a logical property when the inset should follow the writing mode or text direction.

scroll-padding-right Versus scroll-margin-right

Both properties influence scroll alignment at the right edge, but they apply to different elements.

Property Applied To Purpose
scroll-padding-right Scroll container Defines an inset from the right edge of the optimal viewing region.
scroll-margin-right Scroll target Expands or contracts the target's scroll alignment area at its right edge.

Container-Side Scroll Padding

.scroll-container {
  scroll-padding-right: 40px;
}

The container provides a consistent right alignment inset for its scroll targets.

Target-Side Scroll Margin

.scroll-container .featured {
  scroll-margin-right: 20px;
}

The featured target receives additional right-side scroll alignment space.

Combining Both Properties

.scroll-container {
  scroll-padding-right: 40px;
}
.scroll-container .featured {
  scroll-margin-right: 20px;
  scroll-snap-align: end;
}

For left-to-right horizontal end alignment, these values can produce a combined 60-pixel offset between the target's right border edge and the scrollport's right edge.

Important Difference

Scroll padding accepts percentages and auto but not negative values. Scroll margin accepts negative lengths but not percentages or auto.

scroll-padding-right Example

This interactive example compares two horizontal scrolling panels. The second panel uses scroll-padding-right: 50px to align the selected target farther from the right edge.

HTML Example

<div class="scroll-right-demo">
  <div class="scroll-example">
    <h3>Without Scroll Padding</h3>
    <div class="scroll-panel">
      <div class="item">Item 1</div>
      <div class="item">Item 2</div>
      <div class="item target">Target</div>
      <div class="item">Item 4</div>
      <div class="item">Item 5</div>
      <div class="item">Item 6</div>
    </div>
    <button type="button">Scroll to Target</button>
  </div>
  <div class="scroll-example with-padding">
    <h3>With Right Scroll Padding</h3>
    <div class="scroll-panel">
      <div class="item">Item 1</div>
      <div class="item">Item 2</div>
      <div class="item target">Target</div>
      <div class="item">Item 4</div>
      <div class="item">Item 5</div>
      <div class="item">Item 6</div>
    </div>
    <button type="button">Scroll to Target</button>
  </div>
</div>

CSS Example

.scroll-right-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 20px;
}
.scroll-right-demo .scroll-panel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  scroll-snap-type: x mandatory;
}
.scroll-right-demo .item {
  flex: 0 0 110px;
  padding: 25px 10px;
  text-align: center;
  background-color: #e2e8f0;
  scroll-snap-align: end;
}
.scroll-right-demo .target {
  background-color: #bfdbfe;
  border: 2px solid #2563eb;
}
.scroll-right-demo .with-padding .scroll-panel {
  scroll-padding-right: 50px;
}
.scroll-right-demo button {
  margin-top: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

JavaScript Example

document.querySelectorAll(".scroll-right-demo .scroll-example").forEach((example) => {
  const button = example.querySelector("button");
  const target = example.querySelector(".target");
  button.addEventListener("click", () => {
    target.scrollIntoView({
      behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth",
      inline: "end",
      block: "nearest"
    });
  });
});
Browser Result

Without Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

With Right Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

Click each button to bring the target toward the right edge. In the second panel, the 50-pixel scroll padding moves the requested alignment inward from the right edge.

Increasing Right Scroll Padding

.scroll-right-demo .with-padding .scroll-panel {
  scroll-padding-right: 80px;
}

The right alignment inset increases to 80 pixels.

Removing Right Scroll Padding

.scroll-right-demo .with-padding .scroll-panel {
  scroll-padding-right: 0;
}

The additional right alignment inset is removed.

Browser Compatibility Note

The final position depends on available scroll range and scroll snapping behavior. Targets near the beginning or end of the container may not reach the requested alignment.

Accessibility Considerations

Right scroll padding can help keep scroll targets visible when interface elements or overlays occupy part of the scrolling area.

Avoid Obscured Content

Use an appropriate right inset when controls or overlays could cover aligned content.

Maintain Keyboard Accessibility

Ensure carousel controls and other scrolling controls are keyboard accessible and have visible focus indicators.

Consider Focus Management

Programmatic scrolling does not automatically move keyboard focus. Scripted navigation may require additional focus handling.

Respect Reduced Motion Preferences

The property does not animate scrolling. If smooth scrolling is used, respect prefers-reduced-motion.

Support Different Writing Directions

The physical right edge remains fixed when text direction changes. Use logical scroll padding when the inset should follow the writing direction.

Test Responsive Layouts

Verify scroll alignment at different viewport sizes, browser zoom levels, and text scaling settings.

Common Mistakes

Using Negative Values

.container {
  scroll-padding-right: -20px;
}

Negative values are invalid.

Providing Multiple Values

.container {
  scroll-padding-right: 10px 20px;
}

This longhand property accepts only one value.

Assuming Right Always Means Inline-End

The right edge corresponds to inline-end in left-to-right horizontal writing, but to inline-start in right-to-left horizontal writing.

Confusing Scroll Padding With Layout Padding

scroll-padding-right affects scroll alignment, while padding-right adds normal layout spacing.

Applying Scroll Padding to a Target

Apply scroll-padding-right to the scroll container. Use scroll-margin-right on individual targets.

Expecting Automatic Scroll Snapping

The property does not enable scroll snapping by itself.

Ignoring Declaration Order

A later scroll-padding shorthand can override an earlier scroll-padding-right declaration.

Ignoring Physical and Logical Conflicts

Physical and logical scroll padding declarations may affect the same edge. The CSS cascade determines which declaration applies.

Ignoring Available Scroll Range

The browser may not achieve the requested alignment when the container cannot scroll far enough.

Expecting Extra Content Space

Scroll padding does not extend the scrollable content area. Additional layout spacing may be required for edge items.

Important Considerations

Keep the following points in mind when using scroll-padding-right:

  • It defines a scroll alignment inset at the physical right edge.
  • It is a longhand of scroll-padding.
  • Its initial value is auto, and it is not inherited.
  • It accepts one non-negative length, percentage, or auto value.
  • Negative values are invalid.
  • Percentages are relative to the scrollport's width.
  • The affected edge remains right regardless of writing mode or direction.
  • It does not change normal layout spacing or element dimensions.
  • It can influence scroll snapping and programmatic scrolling.
  • It is useful for horizontal carousels and scrolling navigation.
  • It does not create a scroll container or enable scroll snapping.
  • Use scroll-padding-left for the opposite physical edge.
  • Use scroll-padding-inline-end when the inset should follow the logical inline-end edge.
  • Use scroll-margin-right when individual targets need a right-side alignment offset.
  • Available scroll range may limit the final alignment position.
  • Test scrolling behavior across writing modes, directions, and viewport sizes.

Browser Support

The CSS scroll-padding-right property is widely supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.

Support in older browsers may be limited. Scroll snapping behavior can also vary depending on the browser and available scroll range.

For current compatibility information, visit Can I Use? and search for scroll-padding-right.

When unsupported, scrolling generally remains functional, but the requested right alignment inset may not be applied.

Specifications

The scroll-padding-right property is defined in CSS Scroll Snap Module Level 1.

CSS Scroll Snap Module Level 1

The specification defines how scroll padding establishes the optimal viewing region within a scrollport.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: scroll-padding-right