The scroll-margin-block-end property offsets a scroll target at the block-end edge. It is useful when the bottom of an element should not sit flush against the viewport or scroll container when scrolled into view.
01
block-end
Logical bottom.
02
offset
Scroll stop space.
03
length
px, rem, %.
04
target
On the element.
05
footer
End sections.
06
snap
Last panels.
Fundamentals
Introduction
The scroll-margin-block-end property in CSS is used to set the scroll offset at the block-end edge of an element when it is scrolled into view. Along the block axis, this is typically the bottom in horizontal writing modes.
This property is useful for creating space between the block-end side of an element and the scroll container edge, ensuring that the element is not too close to the viewport bottom when it becomes the scroll target.
Definition and Usage
Apply scroll-margin-block-end 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-block shorthand. Use it when only the block-end side needs adjustment.
💡
Beginner Tip
On a normal webpage, scroll-margin-block-end: 2rem often behaves like bottom scroll padding for the target element.
Foundation
📝 Syntax
The syntax for the scroll-margin-block-end property is simple and can be applied to any element.
syntax.css
element{scroll-margin-block-end:value;}
Here, value can be a length value (e.g., 10px, 2em) or a percentage.
Basic Example
block-end.css
.target{scroll-margin-block-end:50px;}
Related Properties
scroll-margin-block-start — offset at the block-start edge
scroll-margin-block — shorthand for start and end
scroll-margin-bottom — physical bottom offset
Defaults
🎯 Default Value
The default value of the scroll-margin-block-end property is 0. This means that no additional margin is added by default when the element is scrolled into view.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
0
Horizontal writing mode
Usually bottom 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-end: 50px;
Specifies a fixed amount of offset at the block-end edge. For example, 20px, 1rem, etc.
percentage
scroll-margin-block-end: 10%;
Specifies a percentage relative to the element’s block size.
50px2rem10%
Context
When to Use scroll-margin-block-end
scroll-margin-block-end helps when the block-end side of a target needs breathing room:
Footer links — Keep page footers from touching the viewport bottom.
Last snap panel — Add space below the final item in a snap scroller.
Scroll containers — Prevent targets from sitting flush against the container’s bottom edge.
Logical layouts — Prefer block-end over hard-coded bottom in international sites.
For the block-start side (usually top), use scroll-margin-block-start instead.
Preview
👀 Live Preview
Scroll inside the box. The yellow target uses scroll-margin-block-end: 2rem.
Scroll target with block-end offset
The target stops with extra space below it at the block-end edge.
Hands-On
Examples Gallery
Start with the reference container example, add block-end space on the last snap panel, link to a footer, and compare block-end-only offset on one section.
📜 Block-End Offset
Add space at the block-end edge when an element is scrolled into view — matching the reference example.
Example 1 — scroll-margin-block-end in a container
In this example, we’ll set a scroll margin at the end of an element to create some space when it is scrolled into view.
index.html
<style>.container{height:200px;overflow-y:scroll;}.target{scroll-margin-block-end:50px;background-color:yellow;}</style><divclass="container"><divclass="target">Scroll to me!</div></div>
/* These are equivalent when only block-end matters */.a{scroll-margin-block-end:2rem;}.b{scroll-margin-block:02rem;}
🧠 How scroll-margin-block-end Works
1
Scroll target is selected
A link, script, or snap rule focuses on an element with scroll-margin-block-end.
Target
2
Block-end snap area grows
The browser adds the specified offset beyond the element’s block-end edge.
Offset
3
Scroll position settles
The element lands with the extra block-end space visible in the scrollport.
Position
=
★
Comfortable end stops
Targets near the bottom no longer feel cramped against the edge.
Compatibility
Browser Compatibility
The scroll-margin-block-end 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-end support
Current Chrome, Firefox, Safari, Edge, and Opera support scroll-margin-block-end.
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 footer and last-panel anchor jumps on mobile browsers to confirm the block-end offset feels right.
scroll-margin-block-end property97% supported
Bottom line:scroll-margin-block-end is safe to use in modern projects for scroll targets near the block-end edge.
Wrap Up
Conclusion
The scroll-margin-block-end property is a useful tool for managing the spacing of elements when they are scrolled into view.
By customizing this property, you can ensure that your elements have appropriate margins, improving the overall user experience. Experiment with different values to see how this property can enhance the look and functionality of your web projects.
Apply scroll-margin-block-end on the scroll target element
Use it on footers and last snap panels
Prefer logical block-end over hard-coded bottom when possible
Test with scrollIntoView() and anchor links
Combine with scroll-behavior: smooth for page jumps
❌ Don’t
Set it on the scroll container expecting container padding
Confuse it with margin-block-end layout spacing
Assume block-end always equals bottom in every writing mode
Use huge percentages without testing on small screens
Forget block-start offset when sticky headers cover titles
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll-margin-block-end
Use these points when offsetting block-end scroll targets.
5
Core concepts
★01
0 Default
No offset.
Default
⚙02
block-end
Logical edge.
Axis
◉03
longhand
One side.
Detail
▦04
footer
End content.
Use case
🔄05
block
Shorthand pair.
Companion
❓ Frequently Asked Questions
scroll-margin-block-end adds scroll offset at the block-end edge of an element when it is scrolled into view. In horizontal writing mode, block-end is usually the bottom.
bottom is a physical direction. block-end 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-end sets only the block-end side.
The default value is 0, meaning no extra block-end offset is applied.
Use it when the bottom of a scroll target should stop above the viewport edge or container bottom, such as for footers, last snap panels, or scrollIntoView targets near the end of content.