CKTIS / CSS
scroll-margin-top — top offset for scrolling
scroll-margin-top specifies the top outset of an element's area used for scrolling it into view and snapping. It does not create spacing in page layout.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
scroll-margin-top: <length>;scroll-margin-top expands an element's scroll snap area upward. It addresses the physical top; scroll-margin-block-start addresses the block-axis start according to the writing mode.
It accepts a <length>, including negative values, but not percentages or auto. Its initial value is 0; it is not inherited and applies to all elements.
Set it on the scroll target, for example to leave room beneath a fixed header. Unlike margin-top, it does not change layout. scroll-padding-top sets the offset on the container side. Scrolling to a target uses this area even without snapping enabled; scroll limits can constrain the resulting gap.
Examples
<!doctype html>
<meta charset="utf-8">
<title>scroll-margin-top</title>
<style>
#scroller { height: 120px; overflow: auto; scroll-behavior: auto; }
.space { height: 200px; }
#target { height: 40px; scroll-margin-top: 24px; background: gold; }
</style>
<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');
target.scrollIntoView({ block: 'start', behavior: 'instant' });
document.getElementById('result').textContent = scroller.scrollTop;
</script>Result
176
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.