Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-padding-left — left scroll viewing inset

scroll-padding-left insets the left edge of a scroll container's optimal viewing region without changing element layout.

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

Syntax

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

scroll-padding-left sets the physical left inset of a scroll container's optimal viewing region. It affects snap alignment and scrolling elements into view, even without scroll-snap-type. It creates neither ordinary padding nor extra layout space.

It accepts a nonnegative length or percentage of the scrollport width. The initial value auto lets the browser choose, usually 0px. The property is not inherited; negative values are invalid.

left always means the left side; scroll-padding-inline-start follows direction and writing mode. Set the property on the container, not the target: scroll-margin-left controls the target's outset.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>scroll-padding-left</title>
<style>
  .scroller {
    width: 300px;
    overflow-x: auto;
    direction: ltr;
    scroll-padding-left: 40px;
  }
  .track { display: flex; width: 900px; }
  .item { flex: 0 0 300px; height: 80px; background: #ddd; }
  #target { background: #9df; }
</style>
<button id="show" type="button">Show target</button>
<div class="scroller">
  <div class="track">
    <div class="item">A</div>
    <div class="item" id="target">B</div>
    <div class="item">C</div>
  </div>
</div>
<script>
  document.getElementById('show').addEventListener('click', () => {
    document.getElementById('target').scrollIntoView({
      behavior: 'instant', block: 'nearest', inline: 'start'
    });
  });
</script>
</html>

Result

After clicking Show target: B starts 40px from the scroller's left edge; the horizontal scroll offset is 260px.

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