The scroll-margin-block property sets scroll offsets on the block axis. It is the logical companion to physical top/bottom scroll margins and works well with scroll snapping and anchor navigation.
01
block
Vertical flow axis.
02
start
Block-start side.
03
end
Block-end side.
04
snap
Scroll snapping.
05
length
px, rem, %.
06
logical
Writing-mode safe.
Fundamentals
Introduction
The scroll-margin-block property in CSS is used to adjust the scroll snap area at the block start and block end of an element.
This property is particularly useful when implementing scroll snapping in a vertical writing mode or when you need to add margins to the scroll snap position. By using this property, you can control the proximity of elements to the container’s scroll position, enhancing the scrolling experience.
Definition and Usage
scroll-margin-block is a logical shorthand for scroll-margin-block-start and scroll-margin-block-end. Apply it to the element that becomes a scroll target.
In standard horizontal writing mode, block-start maps to the top and block-end maps to the bottom. That makes scroll-margin-block: 4rem 1rem similar to setting top and bottom scroll offsets, but it stays correct if the writing mode changes.
💡
Beginner Tip
On a normal English webpage, think of scroll-margin-block as “top and bottom scroll offset” that follows the document’s block direction.
Foundation
📝 Syntax
The syntax for the scroll-margin-block property is straightforward and allows you to specify the margin for the block start and block end.
International layouts — Prefer logical properties over hard-coded top/bottom rules.
Documentation pages — Fine-tune where chapter anchors land vertically.
For left/right offsets, use scroll-margin-inline instead.
Preview
👀 Live Preview
Scroll inside the panel. Each section uses scroll-snap-align: start and scroll-margin-block: 12px.
Section 1
Section 2
Section 3
The block-axis margin creates breathing room when each panel snaps into view.
Hands-On
Examples Gallery
Start with the reference scroll-snap example, set different block-start and block-end values, try a scroll container, and use scroll-margin-block-start with a sticky header.
📜 Block-Axis Offsets
Control scroll stop position on the block axis — matching the reference example.
Example 1 — scroll-margin-block with scroll snap
In this example, we’ll add scroll margin to a section element to ensure it doesn’t touch the edges when snapped into view.
Chapter headings stay visible below the sticky docs header.
How It Works
Longhands let you offset only one logical side when the other side does not need adjustment.
Companion
scroll-margin-block vs scroll-margin
scroll-margin is the physical shorthand for all four sides. scroll-margin-block targets only the block axis and is safer for multilingual layouts.
Pair with scroll-behavior: smooth for animated anchor navigation and with scroll-snap-align for snapped carousels or section scrollers.
logical-vs-physical.css
/* Physical shorthand */.physical{scroll-margin-top:4rem;}/* Logical equivalent in horizontal writing */.logical{scroll-margin-block-start:4rem;}
🧠 How scroll-margin-block Works
1
Block axis is determined
Writing mode decides which sides are block-start and block-end.
Logical
2
Scroll target area grows
scroll-margin-block adds offset on both block edges of the snap area.
Offset
3
Browser scrolls into place
Anchor links, focus, scrollIntoView(), or snap positioning use the expanded area.
Position
=
★
Comfortable block-axis stops
Snapped and linked content lands with space on the block axis.
Compatibility
Browser Compatibility
The scroll-margin-block 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-block 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 scroll snapping and anchor jumps on iOS Safari — block-axis offsets should match your real sticky header height.
scroll-margin-block property97% supported
Bottom line:scroll-margin-block is widely supported in modern browsers for scroll snap and in-page navigation.
Wrap Up
Conclusion
The scroll-margin-block property is a useful tool for web developers looking to fine-tune the scrolling experience on their websites.
By adding margins to the scroll snap area, you can ensure a more comfortable and visually appealing layout. Experiment with different values to see how this property can improve the usability of your scrollable content.
Prefer logical scroll-margin-block for international layouts
Pair with scroll-snap-align on snapped children
Match block-start offset to sticky header height
Use rem for scalable documentation offsets
Test anchor links and snap scrolling on mobile
❌ Don’t
Confuse scroll-margin-block with regular margin-block
Apply it to the scroll container instead of the target
Assume block-start always means top in every writing mode
Forget horizontal offsets when content needs side inset
Use huge percentage values without testing small screens
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll-margin-block
Use these points when offsetting block-axis scroll targets.
5
Core concepts
★01
0 Default
No offset.
Default
⚙02
block axis
Logical flow.
Axis
◉03
start / end
Two sides.
Values
▦04
snap
Scroll snapping.
Use case
🔄05
longhands
block-start.
Detail
❓ Frequently Asked Questions
scroll-margin-block sets the scroll offset on the block axis — block-start and block-end — when an element is scrolled into view. In normal horizontal writing mode, that usually means top and bottom.
scroll-margin is the physical shorthand for all four sides. scroll-margin-block is a logical shorthand that targets only the block axis, which adapts correctly in vertical writing modes.
They are logical directions. In horizontal left-to-right writing, block-start is the top and block-end is the bottom. In vertical writing modes, they map to the corresponding block flow sides.
The default value is 0, meaning no extra block-axis offset is applied to the scroll target.
Use it when you want block-axis scroll offsets that work with logical layout, especially with scroll snapping, anchor links, or scrollIntoView on vertically flowing content.