CSS scroll-margin-block-end Property

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

What You’ll Learn

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.

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.

📝 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

🎯 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.

⚡ Quick Reference

QuestionAnswer
Default value0
Horizontal writing modeUsually bottom scroll offset
Part ofscroll-margin-block shorthand
Accepted valuesLengths and percentages
InheritedNo
AnimatableNo

💎 Property Values

ValueExampleDescription
lengthscroll-margin-block-end: 50px;Specifies a fixed amount of offset at the block-end edge. For example, 20px, 1rem, etc.
percentagescroll-margin-block-end: 10%;Specifies a percentage relative to the element’s block size.
50px 2rem 10%

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.

👀 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.

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>

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

How It Works

The browser expands the scroll snap area at the block-end side before settling the scroll position.

Example 2 — Last snap panel spacing

Add scroll-margin-block-end to the final snapped panel so it does not hug the container bottom.

last-panel.css
.panel:last-child {
  scroll-snap-align: start;
  scroll-margin-block-end: 24px;
}
Try It Yourself

How It Works

Only the final panel needs block-end offset when earlier panels already have natural spacing above.

📄 Page Navigation

Improve anchor jumps to end-of-page content such as footers and closing sections.

Example 4 — Block-end only on one section

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

section-end.css
#section-end {
  scroll-margin-block-end: 3rem;
}
Try It Yourself

How It Works

Longhands let you tune one logical side without affecting block-start.

scroll-margin-block-end in the family

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

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

🧠 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.

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 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 footer and last-panel anchor jumps on mobile browsers to confirm the block-end offset feels right.

scroll-margin-block-end property 97% supported

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

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.

💡 Best Practices

✅ Do

  • 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

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
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.

Practice in the Live Editor

Open the HTML editor and try scroll-margin-block-end: 50px on a 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