Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-padding-inline-start — inset at the inline start of the scrolling region

scroll-padding-inline-start sets an inward offset for the optimal viewing region at a scroll container's inline-start edge. It is not ordinary padding; the logical edge depends on writing direction and writing mode.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

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

scroll-padding-inline-start sets an inset for the scroll alignment region on the inline-start side. It applies to a scroll container, is not inherited, and does not add layout space like padding.

With writing-mode: horizontal-tb and direction: ltr, inline start is on the left; with direction: rtl, it is on the right. In a vertical writing mode, the inline axis is vertical, so inline-start should not be equated with the left side.

Accepted values are auto and nonnegative lengths and percentages. A percentage refers to the corresponding dimension of the scrollport. The initial value, auto, leaves the choice to the browser, generally meaning 0px. This property alone does not enable snapping; use scroll-snap-type for that.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>scroll-padding-inline-start: inset for scroll alignment</title>
  <style>
    #scroller {
      display: flex;
      width: 300px;
      overflow-x: auto;
      writing-mode: horizontal-tb;
      direction: ltr;
      scroll-snap-type: x mandatory;
      scroll-padding-inline-start: 40px;
    }
    .card {
      flex: 0 0 200px;
      height: 80px;
      scroll-snap-align: start;
      background: #dcecff;
      outline: 1px solid #345;
      outline-offset: -1px;
    }
  </style>
</head>
<body>
  <div id="scroller" role="region" aria-label="Scrollable cards" tabindex="0">
    <div class="card">Card A</div>
    <div class="card" id="target">Card B</div>
    <div class="card">Card C</div>
  </div>
  <script>
    const scroller = document.getElementById('scroller');
    const target = document.getElementById('target');
    target.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'start' });
    const inset = target.getBoundingClientRect().left - scroller.getBoundingClientRect().left;
    const style = getComputedStyle(scroller);
    console.log(`Computed inline-start scroll padding: ${style.scrollPaddingInlineStart}; ordinary inline-start padding: ${style.paddingInlineStart}`);
    console.log(`Card start inset: ${inset}px; scrollLeft: ${scroller.scrollLeft}px`);
  </script>
</body>
</html>

Result

Computed inline-start scroll padding: 40px; ordinary inline-start padding: 0px
Card start inset: 40px; scrollLeft: 160px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources