Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-padding-block-start — logical scroll viewing offset

The scroll-padding-block-start property insets the start of a scroll container's optimal viewing region. It helps leave space beside a scrolled target without adding ordinary padding.

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

Syntax

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

scroll-padding-block-start sets an inward offset from a scroll container's block-start edge. The edge depends on writing-mode: it is the top for horizontal-tb and the right for vertical-rl.

It accepts auto or a nonnegative length or percentage of the corresponding scrollport dimension. The initial auto lets the browser choose, usually zero. The property is not inherited.

It does not change layout. However, if the container starts at a snap position, changing the block-start inset can shift that position by moving the snapport's alignment edge. The property defines the region used when scrolling a target into view and for snap alignment; enabling scroll snap is not required. Set it on the container, not the target. It is not ordinary padding.

Examples

<!doctype html>
<meta charset="utf-8">
<title>scroll-padding-block-start</title>
<style>
  #scroller {
    height: 160px;
    overflow: auto;
    writing-mode: horizontal-tb;
    scroll-padding-block-start: 40px;
  }
  .space { height: 200px; }
  #target { height: 40px; background: lightblue; }
</style>
<button id="go">Scroll</button>
<div id="scroller">
  <div class="space"></div>
  <div id="target">Target</div>
  <div class="space"></div>
</div>
<output id="result"></output>
<script>
  const scroller = document.getElementById('scroller');
  const target = document.getElementById('target');
  document.getElementById('go').onclick = () => {
    target.scrollIntoView({ block: 'start', behavior: 'instant' });
    document.getElementById('result').textContent =
      `scrollTop: ${scroller.scrollTop}`;
  };
</script>

Result

scrollTop: 160

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