CKTIS / CSS
scroll-margin-block-start — offset a scroll target at block start
scroll-margin-block-start sets an offset for a scroll target's area on its block-start side. It does not create layout spacing; which physical side it affects depends on writing-mode.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
scroll-margin-block-start: <length>;scroll-margin-block-start modifies an element's scroll snap area on its block-start side. In horizontal-tb this is the top; in vertical-rl it is the right. Unlike margin, it does not push elements apart in layout.
It accepts a <length>, including negative lengths, but not percentages or auto. Its initial value is 0, and it is not inherited. Set it on the target element, whereas scroll-padding-block-start belongs on the scroll container.
This area should be considered for fragment navigation and scrollIntoView(), even without snapping enabled. The available scroll range limits the achievable gap.
Examples
<!doctype html>
<meta charset="utf-8">
<title>scroll-margin-block-start</title>
<style>
#scroller {
height: 160px;
overflow: auto;
writing-mode: horizontal-tb;
}
.space { height: 240px; }
#target {
height: 40px;
scroll-margin-block-start: 24px;
background: gold;
}
</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: 216
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.