The scroll-margin-inline property sets scroll offsets on the inline axis. It is the logical companion to left/right scroll margins and works especially well with horizontal scroll snapping and carousels.
01
inline
Horizontal flow.
02
start
Inline-start.
03
end
Inline-end.
04
snap
x-axis snap.
05
carousel
Side scroll.
06
logical
RTL safe.
Fundamentals
Introduction
The scroll-margin-inline property in CSS is used to define the margin on the inline start and inline end edges of an element when it is scrolled into view.
This property is particularly useful when working with horizontal scroll snapping, allowing you to adjust the scroll offset for elements along the inline axis, which varies based on the writing mode and direction of the document.
Definition and Usage
scroll-margin-inline is a logical shorthand for scroll-margin-inline-start and scroll-margin-inline-end. Apply it to the scroll target element inside a horizontally scrollable container.
In standard LTR horizontal writing mode, inline-start maps to the left and inline-end maps to the right. The property also works with anchor links and scrollIntoView() inside overflow containers.
💡
Beginner Tip
On a normal English webpage, think of scroll-margin-inline as “left and right scroll offset” that follows text direction.
Foundation
📝 Syntax
The syntax for the scroll-margin-inline property is straightforward. You can specify a single value or two values for the inline start and inline end margins.
For vertical offsets, use scroll-margin-block instead.
Preview
👀 Live Preview
Scroll sideways in the demo. Each item uses scroll-snap-align: center and scroll-margin-inline: 0.75rem.
1
2
3
4
5
Inline-axis margin creates side breathing room when each item snaps into view.
Hands-On
Examples Gallery
Start with the reference horizontal snap row, set different inline-start and inline-end values, try a carousel panel, and use the scroll-margin-inline-start longhand on the first slide.
📜 Inline-Axis Offsets
Control scroll stop position on the inline axis — matching the reference example.
Example 1 — Horizontal scroll snap row
In this example, we’ll apply a scroll margin to an element to ensure it snaps with some margin from the container’s edges.
The first slide gets extra space at the inline-start edge only.
How It Works
Longhands let you tune one logical side without affecting inline-end.
Companion
scroll-margin-inline vs physical sides
scroll-margin is the physical shorthand for all four sides. scroll-margin-inline targets only the inline axis and is safer for multilingual and RTL layouts.
Pair horizontal snapping with scroll-margin-block when a layout also needs vertical scroll offsets.
Writing mode and direction decide which sides are inline-start and inline-end.
Logical
2
Scroll target area grows
scroll-margin-inline adds offset on both inline edges of the snap area.
Offset
3
Browser scrolls into place
Horizontal snap, anchor links, or scrollIntoView() use the expanded area.
Position
=
★
Polished sideways scrolling
Carousel items land with comfortable side spacing when snapped.
Compatibility
Browser Compatibility
The scroll-margin-inline property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.
✓ Logical scroll margins · Modern support
Reliable scroll-margin-inline support
Current Chrome, Firefox, Safari, Edge, and Opera support logical scroll-margin properties.
97%Modern browser support
Google Chrome69+ · Desktop & Mobile
Full support
Mozilla Firefox68+ · Desktop & Mobile
Full support
Apple Safari14.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera56+ · Modern versions
Full support
Testing tip
Test horizontal snap carousels on iOS Safari and in RTL mode to confirm inline-start/end behavior.
scroll-margin-inline property97% supported
Bottom line:scroll-margin-inline is widely supported for horizontal scroll snap and in-page navigation in modern browsers.
Wrap Up
Conclusion
The scroll-margin-inline property is a useful tool for adjusting the scroll snapping behavior of elements within a scroll container.
By customizing the margin on the inline axis, you can create a more refined and visually appealing scrolling experience. Experiment with different values to see how this property can improve the layout and usability of your web projects.
Prefer logical scroll-margin-inline for carousels and RTL layouts
Pair with scroll-snap-type: x mandatory on the container
Use two values when inline-start and inline-end need different spacing
Apply offsets on snap children, not the scroll container
Test sideways scrolling on touch devices
❌ Don’t
Confuse scroll-margin-inline with regular margin-inline
Hard-code left/right when logical inline properties are enough
Forget vertical offsets when items also need block-axis space
Assume inline-start always equals left in every writing mode
Use huge percentage values without testing narrow containers
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll-margin-inline
Use these points when offsetting inline-axis scroll targets.
5
Core concepts
★01
0 Default
No offset.
Default
⚙02
inline axis
Side flow.
Axis
◉03
20px
Both sides.
Pattern
▦04
x snap
Carousels.
Use case
🔄05
longhands
inline-start.
Detail
❓ Frequently Asked Questions
scroll-margin-inline sets scroll offset on the inline axis — inline-start and inline-end — when an element is scrolled into view. In horizontal left-to-right writing mode, that usually means left and right.
scroll-margin-inline is a logical shorthand that follows the document inline direction. scroll-margin-left and scroll-margin-right are physical sides.
They are logical directions along the inline axis. In LTR horizontal writing, inline-start is left and inline-end is right. In RTL, they swap.
The default value is 0, meaning no extra inline-axis offset is applied to the scroll target.
Use it for horizontal scroll snapping, carousels, sideways panels, and any scroll target that needs left/right breathing room in logical layouts.