CSS scroll-padding-left Property

The CSS scroll-padding-left property defines an inset from the physical left 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 left edge, particularly in horizontal carousels, scrolling navigation, and interfaces with overlapping controls.

scroll-padding-left Syntax

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

Basic Syntax

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

Available Values

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

CSS-Wide Keywords

.container {
  scroll-padding-left: initial;
}
.container {
  scroll-padding-left: inherit;
}
.container {
  scroll-padding-left: unset;
}
.container {
  scroll-padding-left: revert;
}
.container {
  scroll-padding-left: 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 left inset using a CSS length such as px, rem, or em.
<percentage> Sets the left inset relative to the scrollport's width.
auto Allows the browser to determine an appropriate inset, typically zero.
0 Specifies no additional left 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 Left
Shorthand scroll-padding

Valid Values

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

Invalid Values

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

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

How It Works

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

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

Default Left Scroll Padding

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

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

Fixed Left Inset

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

The optimal viewing region begins 60 pixels inward from the physical left edge.

Percentage-Based Inset

.container {
  scroll-padding-left: 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-left: 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-left, 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-left With Scroll Snap

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

Horizontal Scroll Snap

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

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

Different Left and Right Insets

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

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

Start Alignment

.scroll-container {
  scroll-padding-left: 40px;
}
.scroll-container .item {
  scroll-snap-align: start;
}

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

Combining Scroll Padding and Scroll Margin

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

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

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

Adding Layout Space at the Left Edge

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

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

Responsive Left Insets

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

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

Right-to-Left Carousels

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

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

Important Consideration

Scroll padding does not guarantee additional scroll range at the left 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-left when aligning a target.

Using scrollIntoView()

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

In left-to-right horizontal writing, the target can align approximately 60 pixels inward from the left 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 start 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: "start",
  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: "start" aligns toward the physical right edge, while scroll-padding-left continues to affect the physical left edge.

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 Left Edge

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

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

Declaration Order

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

The later shorthand resets the left 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-left Physical left
scroll-padding-right Physical right
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 Left Inset

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

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

Logical Inline-Start Inset

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

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

Physical Edge Mapping

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

Overlapping Declarations

.container {
  direction: ltr;
  scroll-padding-left: 20px;
  scroll-padding-inline-start: 60px;
}

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

Choosing the Appropriate Property

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

scroll-padding-left Versus scroll-margin-left

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

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

Container-Side Scroll Padding

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

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

Target-Side Scroll Margin

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

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

Combining Both Properties

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

For left-to-right horizontal start alignment, these values can produce a combined 60-pixel offset between the target's left border edge and the scrollport's left 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-left Example

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

HTML Example

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

JavaScript Example

document.querySelectorAll(".scroll-left-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: "start",
      block: "nearest"
    });
  });
});
Browser Result

Without Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

With Left Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

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

Increasing Left Scroll Padding

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

The left alignment inset increases to 80 pixels.

Removing Left Scroll Padding

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

The additional left 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

Left 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 left 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 left 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-left: -20px;
}

Negative values are invalid.

Providing Multiple Values

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

This longhand property accepts only one value.

Assuming Left Always Means Inline-Start

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

Confusing Scroll Padding With Layout Padding

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

Applying Scroll Padding to a Target

Apply scroll-padding-left to the scroll container. Use scroll-margin-left 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-left 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-left:

  • It defines a scroll alignment inset at the physical left 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 left 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-right for the opposite physical edge.
  • Use scroll-padding-inline-start when the inset should follow the logical inline-start edge.
  • Use scroll-margin-left when individual targets need a left-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-left 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-left.

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

Specifications

The scroll-padding-left 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-left