The scroll-margin-block-start property offsets a scroll target at the block-start edge. It is one of the most practical scroll-margin longhands for fixing sticky-header overlap on anchor links.
01
block-start
Logical top.
02
offset
Scroll stop space.
03
sticky
Header fix.
04
anchors
#section links.
05
JS scroll
scrollIntoView.
06
writing mode
Logical layout.
Fundamentals
Introduction
The scroll-margin-block-start property in CSS is used to set the margin at the start of the block axis for an element when it is scrolled into view.
This property is particularly useful for controlling the position of an element when it is brought into view via scrolling, such as with scrollIntoView(). The block axis depends on the element’s writing mode, which means it will be vertical in horizontal writing modes and horizontal in vertical writing modes.
Definition and Usage
Apply scroll-margin-block-start to the element being scrolled to — section headings, chapter articles, snap panels, or any anchor target.
It is the block-start longhand of scroll-margin-block. On a typical English webpage, it often behaves like scroll-margin-top, but stays correct in logical layouts.
💡
Beginner Tip
If a sticky nav covers section titles after clicking in-page links, set scroll-margin-block-start to the header height.
Foundation
📝 Syntax
The syntax for the scroll-margin-block-start property is simple and allows you to set a margin using any CSS length value.
syntax.css
element{scroll-margin-block-start:value;}
Here, value can be a length (e.g., 10px, 2em, 5%, etc.).
Basic Example
block-start.css
.target{scroll-margin-block-start:50px;}
Related Properties
scroll-margin-block-end — offset at the block-end edge
scroll-margin-block — shorthand for start and end
scroll-margin-top — physical top offset
Defaults
🎯 Default Value
The default value of the scroll-margin-block-start property is 0. This means that by default, no additional margin is added at the start of the block axis when the element is scrolled into view.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
0
Horizontal writing mode
Usually top scroll offset
Part of
scroll-margin-block shorthand
Accepted values
Lengths and percentages
Inherited
No
Animatable
No
Reference
💎 Property Values
Value
Example
Description
length
scroll-margin-block-start: 50px;
Specifies a fixed value for the scroll margin. This can be any valid CSS length unit such as px, em, rem, vh, etc.
percentage
scroll-margin-block-start: 10%;
Specifies a percentage relative to the element’s block size.
50px4rem10%
Context
When to Use scroll-margin-block-start
scroll-margin-block-start solves the most common scroll-position problem on documentation sites:
Sticky navigation — Keep section headings visible below a fixed or sticky header.
Anchor links — Improve table-of-contents jumps on long pages.
Scroll snapping — Add top breathing room on the first snapped panel.
For the block-end side (usually bottom), use scroll-margin-block-end instead.
Preview
👀 Live Preview
Scroll inside the box. The blue target uses scroll-margin-block-start: 2.5rem below the sticky label.
Sticky nav simulation
Scroll target with block-start offset
The target stops with extra space at its block-start edge instead of touching the top.
Hands-On
Examples Gallery
Start with the reference container example, fix sticky-header overlap, add block-start space on the first snap panel, and use rem units with a fixed banner.
📜 Block-Start Offset
Add space at the block-start edge when an element is scrolled into view — matching the reference example.
Example 1 — scroll-margin-block-start: 50px
In this example, we’ll set the scroll margin at the start of the block axis to 50px for a paragraph element.
index.html
<style>.container{height:200px;overflow-y:scroll;}.target{scroll-margin-block-start:50px;background-color:lightblue;}</style><divclass="container"><pclass="target">Scroll to me!</p></div><buttononclick="document.querySelector('.target').scrollIntoView();">
Scroll to Target
</button>
/* These are equivalent when only block-start matters */.a{scroll-margin-block-start:4rem;}.b{scroll-margin-block:4rem0;}
🧠 How scroll-margin-block-start Works
1
Writing mode sets block-start
The browser maps block-start based on the element’s writing mode and direction.
Logical
2
Scroll target area grows
scroll-margin-block-start adds offset beyond the block-start edge.
Offset
3
Scroll position settles
Anchor links, focus, scrollIntoView(), or snap rules use the expanded area.
Position
=
★
Readable block-start stops
Headings and targets stay visible, even with sticky UI chrome.
Compatibility
Browser Compatibility
The scroll-margin-block-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 block-start support
Current Chrome, Firefox, Safari, Edge, and Opera support scroll-margin-block-start.
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 anchor navigation on mobile Safari and Chrome with your real sticky header height.
scroll-margin-block-start property97% supported
Bottom line:scroll-margin-block-start is widely supported and ideal for sticky-header anchor fixes in modern projects.
Wrap Up
Conclusion
The scroll-margin-block-start property is a useful tool for web developers aiming to control the scroll position of elements more precisely.
By setting the margin at the start of the block axis, you can ensure that elements are displayed in a visually appealing and accessible manner when scrolled into view. Experiment with different values to see how this property can improve the user experience on your web projects.
Apply scroll-margin-block-start on scroll target elements
Match the offset to sticky or fixed header height
Prefer logical block-start over hard-coded top when possible
Use rem for scalable documentation layouts
Pair with scroll-behavior: smooth for in-page nav
❌ Don’t
Set it on the scroll container expecting padding
Confuse it with margin-block-start layout spacing
Assume block-start always equals top in every writing mode
Forget block-end offset when footers need bottom space
Use huge percentage values without testing small screens
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll-margin-block-start
Use these points when fixing block-start scroll targets.
5
Core concepts
★01
0 Default
No offset.
Default
⚙02
block-start
Logical edge.
Axis
◉03
sticky
Header fix.
Pattern
▦04
longhand
One side.
Detail
🔄05
block
Shorthand pair.
Companion
❓ Frequently Asked Questions
scroll-margin-block-start adds scroll offset at the block-start edge of an element when it is scrolled into view. In horizontal writing mode, block-start is usually the top.
top is a physical direction. block-start is logical and follows the document block flow, so it stays correct in vertical writing modes.
scroll-margin-block is a shorthand for both block-start and block-end. scroll-margin-block-start sets only the block-start side.
The default value is 0, meaning no extra block-start offset is applied.
Use it when a scroll target would sit under a sticky header or too close to the top of the viewport, such as for anchor links, scrollIntoView targets, and snapped panels.