CKTIS / CSS
scroll-margin-inline — logical scrolling offsets
This shorthand sets target-area offsets at the start and end of the inline axis without changing element layout.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
scroll-margin-inline: <length>{1,2};scroll-margin-inline sets scroll-margin-inline-start and scroll-margin-inline-end on the target element. One length applies to both sides; two specify start then end. The initial value is 0; the property is not inherited. Percentages and auto are invalid; negative lengths are allowed.
Logical sides depend on writing-mode and direction, rather than always meaning left and right. Offsets modify the snapping and scroll-into-view area, not the element’s size or layout spacing. By contrast, scroll-padding-inline acts on the scroll container.
The property does not enable snapping itself: use scroll-snap-type and scroll-snap-align for that. It can also affect scroll-into-view operations without snapping. Scroll boundaries may prevent the full offset from being honored.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>scroll-margin-inline: inline snap offsets</title>
<style>
#track {
display: flex;
width: 300px;
overflow-x: auto;
writing-mode: horizontal-tb;
direction: ltr;
scroll-snap-type: x mandatory;
}
#track > div {
flex: 0 0 200px;
height: 80px;
margin: 0;
scroll-snap-align: start;
background: lightblue;
}
#track > #target {
scroll-margin-inline: 20px 40px;
background: coral;
}
</style>
</head>
<body>
<div id="track" role="region" aria-label="Scrollable cards" tabindex="0">
<div>Card A</div><div id="target">Card B</div><div>Card C</div>
</div>
<script>
const track = document.getElementById('track');
const target = document.getElementById('target');
const style = getComputedStyle(target);
target.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'start' });
const card = target.getBoundingClientRect();
const inset = card.left - track.getBoundingClientRect().left;
console.log(`Computed inline scroll margins: ${style.scrollMarginInlineStart} / ${style.scrollMarginInlineEnd}`);
console.log(`Card width: ${card.width}px; card start inset: ${inset}px`);
</script>
</body>
</html>Result
Computed inline scroll margins: 20px / 40px Card width: 200px; card start inset: 20px
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.