CSS scroll-margin-bottom Property

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

What You’ll Learn

The scroll-margin-bottom property adds bottom scroll offset to a target element. It is especially useful in scroll-snap layouts and when footer sections should not sit flush against the viewport bottom.

01

bottom

Physical edge.

02

offset

Scroll stop space.

03

snap

Scroll snapping.

04

footer

End sections.

05

length

px, rem, %.

06

target

On element.

Introduction

The scroll-margin-bottom property in CSS is used to set the bottom scroll offset of an element when it is scrolled into view.

This property is part of the CSS Scroll Snap module and is widely used to control how close an element sits to the bottom edge of a scroll container when it snaps or becomes a scroll target. By using scroll-margin-bottom, you can keep elements a comfortable distance from the container’s bottom edge.

Definition and Usage

Apply scroll-margin-bottom to the element being scrolled to — snap items, footer sections, cards, or any anchor target.

It also works outside pure snap layouts: anchor links, scrollIntoView(), and keyboard focus scrolling all respect bottom scroll margin on the target.

💡
Beginner Tip

On a normal horizontal webpage, scroll-margin-bottom is similar to scroll-margin-block-end, but always refers to the physical bottom edge.

📝 Syntax

The syntax for the scroll-margin-bottom property is straightforward and allows you to specify a length value.

syntax.css
element {
  scroll-margin-bottom: value;
}

Here, value can be any valid CSS length unit such as px, em, rem, %, etc.

Basic Example

scroll-margin-bottom.css
.scroll-item {
  scroll-margin-bottom: 50px;
}

Related Properties

  • scroll-margin-top, scroll-margin-left, scroll-margin-right
  • scroll-margin — shorthand for all four sides
  • scroll-margin-block-end — logical block-end offset

🎯 Default Value

The default value of the scroll-margin-bottom property is 0, meaning there is no additional margin applied by default.

⚡ Quick Reference

QuestionAnswer
Default value0
Edge affectedBottom of the scroll target
Accepted valuesLengths and percentages
Set onScroll target elements
InheritedNo
AnimatableNo

💎 Property Values

ValueExampleDescription
lengthscroll-margin-bottom: 50px;Specifies the bottom margin of the scroll snap area. It can be any valid CSS length unit, such as px, em, rem, %, etc.
percentagescroll-margin-bottom: 10%;Specifies a percentage relative to the element’s dimensions.
50px 2rem 10%

When to Use scroll-margin-bottom

scroll-margin-bottom helps when the bottom of a scroll target needs breathing room:

  • Scroll snapping — Keep snapped cards away from the container bottom.
  • Last list item — Add space below the final panel in a vertical scroller.
  • Footer links — Prevent footers from touching the viewport bottom.
  • JavaScript scrolling — Offset targets reached with scrollIntoView().

For the top edge, use scroll-margin-top or the logical scroll-margin-block-start.

👀 Live Preview

Scroll inside the box. Each item uses scroll-snap-align: start and scroll-margin-bottom: 1.25rem.

Item 1
Item 2
Item 3

Bottom scroll margin creates space when each item becomes the active snap target.

Examples Gallery

Start with the reference snap-container example, jump to a footer, use scrollIntoView(), and add bottom offset on the last snap card.

📜 Bottom Scroll Offset

Control how close the bottom of a target sits to the scroll edge — matching the reference example.

Example 1 — Snap container items

In this example, we’ll set a bottom margin for an element within a scroll container to ensure it snaps into place 50px away from the bottom edge.

index.html
<style>
  .scroll-container {
    height: 200px;
    overflow: auto;
    scroll-snap-type: y mandatory;
  }

  .scroll-item {
    scroll-snap-align: start;
    scroll-margin-bottom: 50px;
  }
</style>

<div class="scroll-container">
  <div class="scroll-item">Item 1</div>
  <div class="scroll-item">Item 2</div>
</div>
Try It Yourself

How It Works

The browser expands the scroll target’s snap area at the bottom before settling the scroll position.

🗃 Scripts & Last Items

Offset programmatic scroll targets and the final item in a snap list.

Example 3 — scrollIntoView with bottom offset

Use scroll-margin-bottom when JavaScript scrolls a target into view inside a container.

target.css
.target {
  scroll-margin-bottom: 40px;
}
Try It Yourself

How It Works

scrollIntoView() respects the target’s scroll-margin values when computing the final position.

Example 4 — Last snap card only

Apply bottom offset only to the final card: .card:last-child { scroll-margin-bottom: 24px; }.

last-card.css
.card:last-child {
  scroll-margin-bottom: 24px;
}
Try It Yourself

How It Works

You often only need bottom offset on the final item in a vertical snap list.

scroll-margin-bottom vs logical properties

scroll-margin-bottom is a physical side property. In horizontal writing mode it often matches scroll-margin-block-end. For international layouts, prefer logical properties when the block axis may change.

See also the shorthand scroll-margin when you need offsets on multiple sides at once.

physical-vs-logical.css
.physical { scroll-margin-bottom: 2rem; }
.logical { scroll-margin-block-end: 2rem; }

🧠 How scroll-margin-bottom Works

1

Scroll target is selected

A snap rule, anchor link, or script focuses on an element with bottom scroll margin.

Target
2

Bottom snap area grows

scroll-margin-bottom adds offset below the element’s box for scroll positioning.

Offset
3

Scroll position settles

The element lands with the requested space above the container or viewport bottom.

Position
=

Comfortable bottom stops

Snapped items and footer targets no longer feel cramped against the edge.

Browser Compatibility

The scroll-margin-bottom 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.

Scroll margins · Modern support

Reliable bottom scroll-margin support

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

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 snap lists and footer anchor jumps on mobile browsers to confirm the bottom offset feels right.

scroll-margin-bottom property 97% supported

Bottom line: scroll-margin-bottom is widely supported for scroll snap and in-page navigation in modern projects.

Conclusion

The scroll-margin-bottom property is a useful tool for web developers looking to enhance the user experience by controlling the scroll position of elements.

By customizing the bottom margin for scroll snapping and scroll targets, you can ensure that elements are positioned exactly where you want them when they come into view. Experiment with different values to see how this property can improve the usability and aesthetics of your web projects.

💡 Best Practices

✅ Do

  • Apply scroll-margin-bottom on scroll target elements
  • Use it on the last item in vertical snap lists
  • Pair footer targets with scroll-behavior: smooth
  • Test with scrollIntoView() inside overflow containers
  • Consider logical scroll-margin-block-end for i18n layouts

❌ Don’t

  • Confuse it with regular margin-bottom layout spacing
  • Set it on the scroll container expecting padding
  • Assume it only works with scroll snapping
  • Forget top offset when sticky headers cover titles
  • Use huge percentage values without testing small screens

Key Takeaways

Knowledge Unlocked

Five things to remember about scroll-margin-bottom

Use these points when offsetting bottom scroll targets.

5
Core concepts
02

bottom

Physical edge.

Side
03

snap

Common use.

Pattern
04

footer

End links.

Use case
🔄 05

block-end

Logical twin.

Companion

❓ Frequently Asked Questions

scroll-margin-bottom adds scroll offset at the bottom edge of an element when it is scrolled into view. It helps prevent targets from sitting flush against the bottom of the viewport or scroll container.
No. It works with scroll snapping, anchor links, focus navigation, and scrollIntoView(). Snap layouts are a common use case, but not the only one.
scroll-margin-bottom is a physical property that always targets the bottom edge. scroll-margin-block-end is logical and follows the block axis, which may map differently in vertical writing modes.
The default value is 0, meaning no extra bottom offset is applied.
Use it when a scroll target near the bottom needs breathing room, such as the last snap panel, a footer anchor target, or an element scrolled to with JavaScript.

Practice in the Live Editor

Open the HTML editor and try scroll-margin-bottom: 50px with scroll-snap-align.

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