CSS scroll-padding-inline-end Property

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

The property adjusts the optimal viewing region used for scroll snapping and other scrolling operations. Unlike physical scroll padding properties, the affected edge depends on the writing mode and text direction, making it useful for right-to-left interfaces, horizontal carousels, and vertical writing systems.

scroll-padding-inline-end Syntax

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

Basic Syntax

selector {
  scroll-padding-inline-end: 40px;
}

Available Values

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

CSS-Wide Keywords

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

Negative values are invalid. The property accepts only one value, unlike the scroll-padding-inline shorthand, which accepts one or two values.

Property Values

Value Description
<length> Sets a non-negative inset using a CSS length such as px, rem, or em.
<percentage> Sets an inset relative to the scrollport's dimension along the inline axis.
auto Allows the browser to determine an appropriate inset, typically zero.
0 Specifies no additional inline-end 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 inline-axis dimension
Negative values Not accepted
Logical edge Inline-end
Shorthand scroll-padding-inline

Valid Values

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

Invalid Values

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

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

How It Works

The scroll-padding-inline-end property establishes an inset from the logical inline-end edge of the scrollport. This adjusts the optimal viewing region used for scroll alignment.

When a target is aligned toward inline-end, the browser can position it inward from that edge rather than directly against the scrollport boundary.

Default Inline-End Scroll Padding

.container {
  scroll-padding-inline-end: auto;
}

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

Fixed Inline-End Inset

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

The optimal viewing region ends 60 pixels before the logical inline-end edge.

Percentage-Based Inset

.container {
  scroll-padding-inline-end: 10%;
}

In horizontal writing, the inset is calculated as 10% of the scrollport's width. In vertical writing, it is based on the scrollport's height.

Relative Lengths

.container {
  scroll-padding-inline-end: 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-inline-end, 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.

Writing Modes and Text Direction

The physical edge controlled by scroll-padding-inline-end depends on the scroll container's writing-mode and direction properties.

Inline-End Edge Mapping

Writing Mode Direction Inline-End Edge
horizontal-tb ltr Right
horizontal-tb rtl Left
vertical-rl ltr Bottom
vertical-rl rtl Top
vertical-lr ltr Bottom
vertical-lr rtl Top

Left-to-Right Horizontal Writing

.container {
  writing-mode: horizontal-tb;
  direction: ltr;
  scroll-padding-inline-end: 50px;
}

The 50-pixel inset applies to the physical right edge.

Right-to-Left Horizontal Writing

.container {
  writing-mode: horizontal-tb;
  direction: rtl;
  scroll-padding-inline-end: 50px;
}

The 50-pixel inset applies to the physical left edge.

Vertical Writing

.container {
  writing-mode: vertical-rl;
  direction: ltr;
  scroll-padding-inline-end: 50px;
}

The inset applies to the physical bottom edge because inline progression runs from top to bottom.

Vertical Right-to-Left Direction

.container {
  writing-mode: vertical-rl;
  direction: rtl;
  scroll-padding-inline-end: 50px;
}

The inset applies to the physical top edge because the inline direction is reversed.

Why Logical Properties Matter

Logical scroll padding adapts to different writing systems without requiring separate physical edge declarations for each direction.

Using scroll-padding-inline-end With Scroll Snap

The scroll-padding-inline-end property is useful when scroll snap targets should align inward from the logical inline-end edge.

Horizontal Scroll Snap

.scroll-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline-end: 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 Start and End Insets

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

The optimal viewing region begins 20 pixels inward from inline-start and ends 60 pixels before inline-end.

End Alignment

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

End-aligned items can snap inward from the inline-end edge.

Combining Scroll Padding and Scroll Margin

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

For end alignment, the values can produce a combined 60-pixel offset between the featured item's inline-end border edge and the corresponding scrollport 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 additional alignment spacing near the end of the scrolling area. The scroll-padding-inline-end 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-inline-end: 40px;
}
.carousel .slide {
  flex: 0 0 250px;
  scroll-snap-align: end;
}

Slides can snap inward from the inline-end edge, leaving a 40-pixel alignment inset.

Adding Layout Space at the End

.carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-inline-end: 40px;
  scroll-padding-inline-end: 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 Inline-End Insets

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

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

Right-to-Left Carousels

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

In right-to-left horizontal writing, inline-end corresponds to the physical left edge.

Important Consideration

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

Programmatic Scrolling

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

Using scrollIntoView()

.scroll-container {
  scroll-padding-inline-end: 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 inline-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

Scroll padding influences target alignment. It does not control scrolling speed, animation timing, or keyboard focus.

Using the scroll-padding-inline Shorthand

The scroll-padding-inline shorthand sets the scroll padding insets for both logical inline edges.

One Value

.container {
  scroll-padding-inline: 30px;
}

Both inline-start and inline-end receive 30 pixels.

Two Values

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

Inline-start receives 20 pixels, and inline-end receives 60 pixels.

Equivalent Longhand Declarations

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

These declarations produce the same logical insets as the two-value shorthand.

Overriding Inline-End

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

The inline-end inset becomes 60 pixels, while inline-start remains 20 pixels.

Declaration Order

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

The later shorthand resets both inline insets to 20 pixels.

Using the Four-Edge Shorthand

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

The physical edges initially receive 20 pixels. The later logical longhand changes the edge corresponding to inline-end to 60 pixels.

Logical Versus Physical Scroll Padding

Logical scroll padding follows the writing mode and text direction. Physical scroll padding always refers to fixed top, right, bottom, or left edges.

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

Physical Right Inset

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

The inset always applies to the physical right edge.

Logical Inline-End Inset

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

The inset follows inline-end, which may be right, left, top, or bottom.

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-inline-end when the inset should follow the writing direction. Use a physical property when alignment must remain tied to a particular physical edge.

scroll-padding-inline-end Versus scroll-margin-inline-end

Both properties influence scroll alignment at the logical inline-end edge, but they apply to different elements.

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

Container-Side Scroll Padding

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

The container provides a consistent inline-end alignment inset for its scroll targets.

Target-Side Scroll Margin

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

The featured target receives additional inline-end scroll alignment space.

Combining Both Properties

.scroll-container {
  scroll-padding-inline-end: 40px;
}
.scroll-container .featured {
  scroll-margin-inline-end: 20px;
}

For inline-end alignment, these values can produce a combined 60-pixel offset between the target's inline-end border edge and the corresponding scrollport 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-inline-end Example

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

HTML Example

<div class="scroll-inline-end-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 Inline-End 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-inline-end-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 20px;
}
.scroll-inline-end-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-inline-end-demo .item {
  flex: 0 0 110px;
  padding: 25px 10px;
  text-align: center;
  background-color: #e2e8f0;
  scroll-snap-align: end;
}
.scroll-inline-end-demo .target {
  background-color: #bfdbfe;
  border: 2px solid #2563eb;
}
.scroll-inline-end-demo .with-padding .scroll-panel {
  scroll-padding-inline-end: 50px;
}
.scroll-inline-end-demo button {
  margin-top: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

JavaScript Example

document.querySelectorAll(".scroll-inline-end-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 Inline-End Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

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

Increasing Inline-End Scroll Padding

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

The inline-end alignment inset increases to 80 pixels.

Removing Inline-End Scroll Padding

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

The additional inline-end 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

Inline-end 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 inline-end 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 Right-to-Left Layouts

Logical scroll padding follows the inline-end edge when text direction changes, reducing the need for separate physical edge rules.

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-inline-end: -20px;
}

Negative values are invalid.

Providing Multiple Values

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

This longhand property accepts only one value.

Assuming Inline-End Always Means Right

Inline-end is the right edge in left-to-right horizontal writing, but it can be left, top, or bottom in other writing modes.

Confusing Scroll Padding With Layout Padding

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

Applying Scroll Padding to a Target

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

Expecting Automatic Scroll Snapping

The property does not enable scroll snapping by itself.

Ignoring Declaration Order

A later scroll-padding-inline or scroll-padding shorthand can override an earlier inline-end 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-inline-end:

  • It defines a scroll alignment inset at the logical inline-end edge.
  • It is a longhand of scroll-padding-inline.
  • 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 inline-axis dimension.
  • The physical edge depends on writing mode and text 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 right-to-left interfaces.
  • It does not create a scroll container or enable scroll snapping.
  • Use scroll-padding-inline-start for the opposite logical inline edge.
  • Use scroll-padding-block-end for the logical block-end edge.
  • Use scroll-margin-inline-end when individual targets need an inline-end 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-inline-end property is supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.

Support in older browsers may be limited, particularly for logical scroll padding properties and vertical writing modes.

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

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

Specifications

The scroll-padding-inline-end 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-inline-end