Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-margin-block-end — block-end scrolling outset

scroll-margin-block-end defines an outset of an element’s scroll snap area on the block-end side. It affects scrolling alignment without creating spacing in layout.

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

Syntax

scroll-margin-block-end: <length>;

scroll-margin-block-end sets an outset of an element’s scroll snap area at the block-end edge. It accepts a <length>, including negative values, but not percentages or auto. Its initial value is 0; it is not inherited.

The edge depends on writing-mode: it is the bottom in horizontal-tb and the left side in vertical-rl. Do not treat this property as an unconditional equivalent of scroll-margin-bottom.

Unlike margin, it does not change layout. Apply it to the scrolling target; apply scroll-padding-block-end to the container. It does not enable snapping by itself.

The example uses scrollIntoView({ block: 'end', behavior: 'instant' }) without snapping. The expected scrollTop: 144 follows from 240 + 40 + 24 - 160. Content after the target prevents the scrolling limit from blocking the outset.

Examples

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

Result

scrollTop: 144

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