CSS scroll-margin-inline-start Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Logical Properties

What You’ll Learn

The scroll-margin-inline-start property offsets a scroll target at the inline-start edge. It is useful when the leading side of an element should not sit flush against the viewport or scroll container when scrolled into view.

01

inline-start

Logical leading edge.

02

offset

Scroll stop space.

03

length

px, rem, %.

04

target

On the element.

05

carousel

First slides.

06

snap

Horizontal panels.

Introduction

The scroll-margin-inline-start property in CSS is used to set the scroll offset at the inline-start edge of an element when it is scrolled into view. Along the inline axis, this is typically the left side in horizontal left-to-right writing modes.

This property is particularly useful when you want to adjust the scroll position so content is not too close to the inline-start edge of the viewport or scroll container when it is brought into view.

Definition and Usage

Apply scroll-margin-inline-start 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-inline shorthand. Use it when only the inline-start side needs adjustment.

💡
Beginner Tip

On a normal English webpage, scroll-margin-inline-start: 20px often behaves like left-side scroll padding for the target element.

📝 Syntax

The syntax for the scroll-margin-inline-start property is straightforward. You can specify the margin value using any valid CSS length unit.

syntax.css
element {
  scroll-margin-inline-start: length | percentage;
}

Here, length can be a value in pixels (px), em units (em), rem units (rem), percentages (%), or any other valid CSS length unit.

Basic Example

inline-start.css
.item {
  scroll-margin-inline-start: 20px;
}

Related Properties

  • scroll-margin-inline-end — offset at the inline-end edge
  • scroll-margin-inline — shorthand for start and end
  • scroll-margin-left — physical left offset

🎯 Default Value

The default value of the scroll-margin-inline-start property is 0. This means that, by default, there is no additional margin applied at the inline-start edge when the element is scrolled into view.

⚡ Quick Reference

QuestionAnswer
Default value0
LTR horizontal writingUsually left scroll offset
Part ofscroll-margin-inline shorthand
Accepted valuesLengths and percentages
InheritedNo
AnimatableNo

💎 Property Values

ValueExampleDescription
lengthscroll-margin-inline-start: 20px;A specific length value, such as 10px, 2em, 1rem, etc.
percentagescroll-margin-inline-start: 10%;A percentage of the containing block’s inline size, such as 10%.
20px 2rem 10%

When to Use scroll-margin-inline-start

scroll-margin-inline-start helps when the inline-start side of a target needs breathing room:

  • First carousel slide — Keep the opening card from hugging the container’s leading edge.
  • Horizontal snap rows — Add space before the first snapped item when swiping sideways.
  • Scroll targets in panels — Prevent targets from stopping flush against the inline-start edge.
  • Logical layouts — Prefer inline-start over hard-coded left in international sites.

For the inline-end side (usually right in LTR), use scroll-margin-inline-end instead.

👀 Live Preview

Scroll sideways in the demo. Each item uses scroll-snap-align: center and scroll-margin-inline-start: 1.25rem.

1
2
3
4

Inline-start margin creates leading-edge breathing room when each item snaps into view.

Examples Gallery

Start with the reference scroll target example, add inline-start space on the first snap slide, improve a carousel opening panel, and use the longhand on one slide only.

📜 Inline-Start Offset

Add space at the inline-start edge when an element is scrolled into view — matching the reference example.

Example 1 — scroll-margin-inline-start in a container

In this example, we’ll add a margin of 20px to the inline-start edge of a target element when it is scrolled into view.

index.html
<style>
  .container {
    width: 200px;
    height: 200px;
    overflow: auto;
    border: 1px solid #334155;
  }

  .content {
    width: 500px;
    height: 500px;
  }

  .target {
    scroll-margin-inline-start: 20px;
    background-color: lightblue;
    width: 100px;
    height: 100px;
    margin: 200px 0;
  }
</style>

<div class="container">
  <div class="content">
    <div class="target">Scroll to me</div>
  </div>
</div>
Try It Yourself

How It Works

The browser expands the scroll snap area at the inline-start side before settling the scroll position.

Example 2 — First snap slide spacing

Add scroll-margin-inline-start to the first snapped slide so it does not hug the container’s leading edge.

first-slide.css
.slide:first-child {
  scroll-snap-align: start;
  scroll-margin-inline-start: 24px;
}
Try It Yourself

How It Works

Only the opening slide needs inline-start offset when later slides already have natural spacing on the inline-end side.

📄 Horizontal Layouts

Improve sideways scroll experiences such as carousels, tab strips, and overflow toolbars.

Example 4 — Inline-start only on one slide

Use the longhand when only the inline-start side needs adjustment: scroll-margin-inline-start: 3rem;.

slide-start.css
#slide-start {
  scroll-margin-inline-start: 3rem;
}
Try It Yourself

How It Works

Longhands let you tune one logical side without affecting inline-end.

scroll-margin-inline-start in the family

scroll-margin-inline-start is the inline-start longhand of scroll-margin-inline. For the opposite side, see scroll-margin-inline-end.

shorthand-equivalent.css
/* These are equivalent when only inline-start matters */
.a { scroll-margin-inline-start: 2rem; }
.b { scroll-margin-inline: 2rem 0; }

🧠 How scroll-margin-inline-start Works

1

Scroll target is selected

A link, script, or snap rule focuses on an element with scroll-margin-inline-start.

Target
2

Inline-start snap area grows

The browser adds the specified offset beyond the element’s inline-start edge.

Offset
3

Scroll position settles

The element lands with the extra inline-start space visible in the scrollport.

Position
=

Comfortable inline-start stops

Targets near the leading edge no longer feel cramped against the container side.

Browser Compatibility

The scroll-margin-inline-start 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 inline-start support

Current Chrome, Firefox, Safari, Edge, and Opera support scroll-margin-inline-start.

97% Modern browser support
Google Chrome 69+ · Desktop & Mobile
Full support
Mozilla Firefox 68+ · Desktop & Mobile
Full support
Apple Safari 14.1+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 56+ · Modern versions
Full support

Testing tip

Test first-slide and carousel anchor jumps on mobile browsers to confirm the inline-start offset feels right.

scroll-margin-inline-start property 97% supported

Bottom line: scroll-margin-inline-start is safe to use in modern projects for scroll targets near the inline-start edge.

Conclusion

The scroll-margin-inline-start property is a useful tool for adjusting the scroll position of elements within a scroll container.

By setting an appropriate margin, you can ensure that content is displayed at a comfortable distance from the inline-start edge of the viewport, enhancing the overall user experience. Experiment with different margin values to see how this property can improve the layout and accessibility of your web projects.

💡 Best Practices

✅ Do

  • Apply scroll-margin-inline-start on the scroll target element
  • Use it on the first carousel slide or opening horizontal snap panel
  • Prefer logical inline-start over hard-coded left when possible
  • 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-inline-start layout spacing
  • Assume inline-start always equals left in every writing mode
  • Use huge percentages without testing on small screens
  • Forget inline-end offset when the trailing edge also needs space

Key Takeaways

Knowledge Unlocked

Five things to remember about scroll-margin-inline-start

Use these points when offsetting inline-start scroll targets.

5
Core concepts
02

inline-start

Logical edge.

Axis
03

longhand

One side.

Detail
04

carousel

First slides.

Use case
🔄 05

inline

Shorthand pair.

Companion

❓ Frequently Asked Questions

scroll-margin-inline-start adds scroll offset at the inline-start edge of an element when it is scrolled into view. In horizontal left-to-right writing mode, that usually means the left side.
left is a physical direction. inline-start is logical and follows the document inline direction, so it stays correct in RTL and vertical writing modes.
scroll-margin-inline is a shorthand for both inline-start and inline-end. scroll-margin-inline-start sets only the inline-start side.
The default value is 0, meaning no extra inline-start offset is applied.
Use it when the inline-start side of a scroll target should stop before the container edge, such as for the first carousel slide, opening horizontal snap panel, or targets inside sideways scroll areas.

Practice in the Live Editor

Open the HTML editor and try scroll-margin-inline-start: 20px on a horizontal scroll target.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful