CSS Portal

CSS scroll-padding-inline 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-inline property defines an inset on the inline axis of a scroll container that establishes a “safe” area between the container edges and the content when snapping or programmatic scrolling occurs. Rather than altering the box model or visual padding of children, it shifts the reference frame used by scrolling algorithms so that targets align away from the physical edge by the specified inset. This makes it easier to ensure focused or snapped items are not flush against the viewport edge and remain visually comfortable and accessible.

Because it is a logical property, scroll-padding-inline follows the writing mode and direction of the document: in left-to-right horizontal text it corresponds to left/right offsets, while in vertical or right-to-left layouts it maps to the appropriate inline sides. It is commonly used together with the shorthand scroll-padding (which sets both inline and block insets) and with snapping behavior controlled by scroll-snap-type to fine-tune where snap points land relative to the visible area. Importantly, it affects the scroll position calculations and snap alignment, not the size or flow of content.

Practical use cases include horizontal carousels where you want an item centered or inset from edges when scrolled into view, navigable lists where focused elements must remain readable and not obscured by UI chrome, and any layout that must adapt to different writing directions. When pairing scrolling alignment with how individual elements are positioned when brought into view, developers often combine scroll-padding-inline with per-element offsets like scroll-margin-inline so that both the container’s safe area and the element’s own preferred offset are respected. In short, use scroll-padding-inline to control the scroll-port’s inline guard space used by snapping and programmatic scrolling without modifying layout padding.

Definition

Initial value
See individual properties
Applies to
scroll containers
Inherited
no
Computed value
See individual properties
Animatable
by computed value type
JavaScript syntax
object.style.scrollPaddingInline

Interactive Demo

1
2
3
Scroll »

Syntax

scroll-padding-inline: auto | &tl;length-percentage [0,∞]>

Values

  • autoThe offset is determined by the user agent. This will generally be 0px, but a user agent is able to detect and do something else if a non-zero value is more appropriate.
  • &tl;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-inline demo</h2>
<div class="scroll-container" tabindex="0">
<section class="card">Item 1</section>
<section class="card">Item 2</section>
<section class="card">Item 3</section>
<section class="card">Item 4</section>
<section class="card">Item 5</section>
</div>
<p class="note">Use keyboard or trackpad to scroll. Items snap with inline padding.</p>
</div>
/* Basic page layout */
* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; margin: 24px; }

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

.scroll-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 16px 0;

  /* Enable horizontal scroll snapping */
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

  /* Add inline padding so snapped items don't sit flush against the container edges */
  scroll-padding-inline: 3rem; /* equivalent to scroll-padding-left/right */

  -webkit-overflow-scrolling: touch;
}

.card {
  min-width: 260px;
  flex: 0 0 auto;
  scroll-snap-align: start;
  background: linear-gradient(180deg, #ffffff, #f3f6ff);
  border: 1px solid rgba(20, 40, 80, 0.08);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(22, 46, 84, 0.06);
  font-size: 18px;
}

.note { color: #556; margin-top: 12px; font-size: 14px; }

Browser Support

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