CKTIS / CSS
scroll-margin-right — right-side scrolling offset
scroll-margin-right sets the physical right-side outset of an element's area used when scrolling to it, without changing layout.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
scroll-margin-right: <length>;scroll-margin-right offsets the right edge of an element's scroll snap area. It does not create layout spacing like margin-right.
It accepts a <length>, including negative values; percentages and auto are invalid. Its initial value is 0; it is not inherited.
Set it on the target element; scroll-padding-right belongs on the container. right means physical right regardless of text direction. The offset also applies to scrollIntoView() without snapping; scroll boundaries can limit its effect.
Examples
<!doctype html>
<meta charset="utf-8">
<title>scroll-margin-right</title>
<style>
#scroller {
width: 300px;
overflow-x: auto;
direction: ltr;
writing-mode: horizontal-tb;
}
#track { display: flex; width: 900px; }
#track > div { flex: 0 0 300px; height: 80px; }
#target { background: lightblue; scroll-margin-right: 24px; }
</style>
<button id="show">Show target</button>
<div id="scroller">
<div id="track">
<div>A</div><div id="target">B</div><div>C</div>
</div>
</div>
<pre id="result"></pre>
<script>
const scroller = document.getElementById('scroller');
const target = document.getElementById('target');
document.getElementById('show').onclick = () => {
target.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'end' });
requestAnimationFrame(() => {
document.getElementById('result').textContent =
`scrollLeft: ${Math.round(scroller.scrollLeft)}`;
});
};
</script>Result
scrollLeft: 324
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.