CSS Portal

CSS scroll-margin-inline-start Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The scroll-margin-inline-start property defines a logical offset on the start side of the inline axis that the browser uses when bringing an element into view. It does not change the element’s layout box or affect how surrounding content flows; instead it tells the user agent to stop scrolling a bit earlier (or later) than the element’s border when that element becomes the target of programmatic or snap-based scrolling. Because it is a logical property, its effect follows the document’s writing mode and direction: “inline start” may be left, right, or another side depending on the writing-mode and the direction of the text.

This property is intended for visual adjustment of scroll positioning without altering document geometry — for example, creating breathing room between a scrolled-to item and an overlaid header, or ensuring a snapped item isn’t flush against the container edge. It interacts directly with the browser’s scroll-to and scroll-snapping behaviors: when an element is scrolled into view or matched as a snap point, the engine respects the scroll-margin-inline-start offset when calculating the final scroll position. For clarifying how this differs from moving the element itself, see margin-inline-start.

In multi-axis or complex layouts this property composes with other scroll-related logical properties. The element-level scroll margin family can be managed together with the shorthand scroll-margin, while container-side adjustments that affect the visible snap area are handled by scroll-padding. It also complements snap alignment settings such as scroll-snap-align, where the margin shifts the apparent alignment target without changing the snap alignment rule itself. In practice, use scroll-margin-inline-start when you need a consistent visual offset for scrolled or snapped elements (especially across different writing modes) while keeping layout metrics intact.

Definition

Initial value
0
Applies to
all elements
Inherited
no
Computed value
as specified
Animatable
by computed value type
JavaScript syntax
object.style.scrollMarginInlineStart

Interactive Demo

1
2
3
Scroll »

Syntax

scroll-margin-inline-start: >length<

Values

  • >length<An outset from the corresponding edge of the scroll container.

Example

<nav class="links">
<a href="#item-2">Scroll to item 2 (no margin)</a>
<a href="#item-4">Scroll to item 4 (with scroll-margin-inline-start)</a>
</nav>

<div class="track" tabindex="0">
<section id="item-1" class="card">Item 1</section>
<section id="item-2" class="card">Item 2</section>
<section id="item-3" class="card">Item 3</section>
<section id="item-4" class="card with-margin">Item 4 (margin)</section>
<section id="item-5" class="card">Item 5</section>
</div>
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    padding: 24px;
    color: #222;
}

.links {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.links a {
    text-decoration: none;
    padding: 8px 12px;
    background: #0366d6;
    color: white;
    border-radius: 6px;
}

.track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
}

.card {
    min-width: 220px;
    min-height: 120px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    scroll-snap-align: start;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* This element will be offset from the inline-start edge when scrolled into view */
.with-margin {
    scroll-margin-inline-start: 80px;
    background: #cfe8ff;
}

Browser Support

The following information will show you the current browser support for the CSS scroll-margin-inline-start property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!