The scroll-margin-left property offsets a scroll target at the left edge. It is useful when you want space between the left side of the viewport or scroll container and the element being scrolled into view.
01
left
Physical left edge.
02
offset
Scroll stop space.
03
length
px, rem, %.
04
target
On the element.
05
carousel
First slides.
06
snap
Horizontal panels.
Fundamentals
Introduction
The scroll-margin-left property in CSS is used to set the left margin of an element when it is scrolled into view.
This property is particularly useful when you want to create space between the left edge of the viewport and the scrolled-to element, ensuring it is not flush against the edge.
Definition and Usage
Apply scroll-margin-left to the element being scrolled to — not to the scroll container itself. It works with anchor links, scrollIntoView(), focus navigation, and scroll snapping.
It is one longhand of the scroll-margin shorthand. In LTR layouts it often behaves like scroll-margin-inline-start, but it always targets the physical left edge.
💡
Beginner Tip
scroll-margin-left: 50px tells the browser to leave 50px of space to the left of the target when it becomes the scroll destination.
Foundation
📝 Syntax
The syntax for the scroll-margin-left property is straightforward. You can specify a length value using units such as px, em, rem, %, and more.
The default value of the scroll-margin-left property is 0. This means there is no additional margin applied when the element is scrolled into view by default.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
0
LTR horizontal writing
Left scroll offset
Part of
scroll-margin shorthand
Accepted values
Lengths and percentages
Inherited
No
Animatable
No
Reference
💎 Property Values
Value
Example
Description
length
scroll-margin-left: 50px;
Specifies the margin as a length value in units like px, em, rem, or %. For example, 20px, 2em, 10%.
percentage
scroll-margin-left: 10%;
A percentage of the containing block’s inline size, such as 10%.
50px2rem10%
Context
When to Use scroll-margin-left
scroll-margin-left helps when the left side of a target needs breathing room:
First carousel card — Keep the opening card from hugging the container’s left edge.
Horizontal snap rows — Add space before the first snapped item when swiping sideways.
Fixed side UI — Offset targets so they do not sit under a sticky left sidebar or toolbar.
Anchor jumps — Improve in-page navigation when a target should not touch the left viewport edge.
For RTL or international layouts, consider scroll-margin-inline-start instead of hard-coded left rules.
Preview
👀 Live Preview
Scroll sideways in the demo. Each item uses scroll-snap-align: center and scroll-margin-left: 1.25rem.
1
2
3
4
Left scroll margin creates breathing room on the leading side when each item snaps into view.
Hands-On
Examples Gallery
Start with the reference page-scroll example, add left space on the first snap slide, improve a carousel opening panel, and apply left offset on one slide only.
📜 Left Offset
Add space at the left edge when an element is scrolled into view — matching the reference example.
Example 1 — scroll-margin-left on a page target
In this example, we’ll add a left margin of 50px when the element is scrolled into view.
index.html
<style>.scroll-margin-example{scroll-margin-left:50px;margin-top:100vh;}</style><h1>CSS scroll-margin-left Example</h1><p>Scroll down to see the effect.</p><divclass="scroll-margin-example">
Scroll to this element
</div>
/* These are equivalent when only left matters */.a{scroll-margin-left:2rem;}.b{scroll-margin:0002rem;}
🧠 How scroll-margin-left Works
1
Scroll target is selected
A link, script, or snap rule focuses on an element with scroll-margin-left.
Target
2
Left snap area grows
The browser adds the specified offset beyond the element’s left edge.
Offset
3
Scroll position settles
The element lands with the extra left-side space visible in the scrollport.
Position
=
★
Comfortable left stops
Targets no longer feel cramped against the left edge of the container or viewport.
Compatibility
Browser Compatibility
The scroll-margin-left 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.
✓ Physical scroll margins · Modern support
Reliable left-side support
Current Chrome, Firefox, Safari, Edge, and Opera support scroll-margin-left.
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 first-slide and anchor jumps on mobile browsers to confirm the left offset feels right.
scroll-margin-left property97% supported
Bottom line:scroll-margin-left is safe to use in modern projects for scroll targets that need left-side offset.
Wrap Up
Conclusion
The scroll-margin-left property is a useful tool for web developers looking to control the positioning of elements when they are scrolled into view.
By adding a left margin, you can ensure that important elements are not obscured by the edge of the viewport, improving the user experience. Experiment with different values to see how this property can enhance the layout and navigation of your web projects.
Apply scroll-margin-left on the scroll target element
Use it on the first carousel slide or opening horizontal snap panel
Use scroll-margin-inline-start instead when you need RTL-safe logical layout
Test with scrollIntoView() and anchor links
Combine with horizontal scroll-snap-type for carousels
❌ Don’t
Set it on the scroll container expecting container padding
Confuse it with margin-left layout spacing
Assume left offset is always correct in RTL writing modes
Use huge percentages without testing on small screens
Forget scroll-margin-right when the right edge also needs space
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll-margin-left
Use these points when offsetting left scroll targets.
5
Core concepts
★01
0 Default
No offset.
Default
⚙02
left
Physical edge.
Axis
◉03
longhand
One side.
Detail
▦04
carousel
First slides.
Use case
🔄05
scroll-margin
Four-side shorthand.
Companion
❓ Frequently Asked Questions
scroll-margin-left adds scroll offset at the left edge of an element when it is scrolled into view. It helps prevent targets from sitting flush against the left side of the viewport or scroll container.
No. It works with anchor links, focus navigation, scrollIntoView(), and scroll snapping in any scroll container. Horizontal layouts are a common use case because left offset is easy to see when scrolling sideways.
scroll-margin-left is a physical property that always targets the left edge. scroll-margin-left is logical and follows the inline direction, which may map to the right in RTL writing modes.
The default value is 0, meaning no extra left offset is applied.
Use it when a scroll target should stop before the left edge, such as the first carousel card, a horizontal snap item, or an element scrolled to inside an overflow panel.