CSS scroll-padding-top Property

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

What You’ll Learn

The scroll-padding-top property insets the scrollport at the top edge of a scroll container. It helps ensure content is not too close to the top when scrolling or scroll snapping.

01

top

Physical edge.

02

inset

Scrollport space.

03

length

px, rem, %.

04

container

On scroll box.

05

header

Top inset.

06

snap

First panels.

Introduction

The scroll-padding-top property in CSS is part of the CSS Scroll Snap Module. It allows you to define inset at the top of a scroll container’s scrollport, ensuring that content is not too close to the top edge when it is scrolled into view.

This property is especially useful for improving readability and usability when fixed headers, sticky navigation, or browser chrome would otherwise cover snapped content.

Definition and Usage

Apply scroll-padding-top to the scroll container — such as html or an element with overflow: auto and scroll snapping enabled.

It is one longhand of the scroll-padding shorthand. Use it when only the top side of the scrollport needs inset.

💡
Beginner Tip

On a normal webpage, scroll-padding-top: 20px insets the top of the scrollport so the first snap item is not hidden under a fixed header.

📝 Syntax

The syntax for the scroll-padding-top property is straightforward. It can be applied to any scroll container.

syntax.css
element {
  scroll-padding-top: length | percentage | auto;
}

Basic Example

top.css
.scroll-container {
  scroll-padding-top: 20px;
}

Related Properties

  • scroll-padding-bottom, scroll-padding-left, scroll-padding-right
  • scroll-padding — shorthand for all four sides
  • scroll-padding-block-start — logical block-start inset

🎯 Default Value

The default value of the scroll-padding-top property is auto, which means the user agent determines the padding based on its default settings unless you specify a length or percentage.

⚡ Quick Reference

QuestionAnswer
Default valueauto
Horizontal writing modeTop scrollport inset
Part ofscroll-padding shorthand
Accepted valuesLengths, percentages, auto
Set onScroll containers
InheritedNo
AnimatableNo

💎 Property Values

ValueExampleDescription
lengthscroll-padding-top: 50px;Specifies a fixed amount of inset at the top edge (e.g., 20px, 2em).
percentagescroll-padding-top: 10%;Specifies inset as a percentage of the scroll container’s block dimension.
autoscroll-padding-top: auto;Lets the browser determine the padding automatically.
50px 2rem 10%

When to Use scroll-padding-top

scroll-padding-top helps when the top side of the scrollport needs inset:

  • Fixed headers — Inset the scrollport so top content is not hidden under fixed UI.
  • First snap panel — Add space above the opening snap stop in a scroller.
  • Scroll containers — Prevent snapped content from sitting flush against the container top.
  • Overflow panels — Keep the first line of content visible below the scroll box edge.

For logical block-axis inset, consider scroll-padding-block-start instead. For the bottom edge, use scroll-padding-bottom.

👀 Live Preview

Scroll inside the box. The container uses scroll-padding-top: 2rem.

Content inside scrollport
Second panel

The scrollport is inset at the top edge so content stops below the container top.

Examples Gallery

Start with the reference vertical snap example, inset a snap scroller at the top, add page top inset for fixed headers, and use the longhand alone on a scroll box.

📜 Top Scrollport Inset

Inset the scrollport at the top edge inside a scroll container — matching the reference example.

Example 1 — scroll-padding-top on a scroll container

In this example, we’ll set the top scroll padding to 20px so content snaps with space at the top.

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

  .snap-item {
    height: 200px;
    scroll-snap-align: start;
    background-color: lightcoral;
    margin-bottom: 10px;
  }
</style>

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

How It Works

The scroll container’s snap area is inset from the top edge before the browser settles the position of each panel.

Example 2 — Snap scroller top inset

Add scroll-padding-top to a vertical snap container so the first panel does not hug the top edge.

snap-scroller.css
.snap-box {
  overflow: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-top: 24px;
}
Try It Yourself

How It Works

Container-level top inset applies to every snap stop inside the scroll box.

📄 Page & Layout Insets

Improve top spacing on page scrollports and overflow panels.

Example 3 — Page top inset

Set scroll-padding-top on html so page scrolling leaves space at the top edge for fixed headers.

page-top.css
html {
  scroll-padding-top: 2rem;
}
Try It Yourself

How It Works

Page-level inset helps top content stay visible below fixed headers or browser chrome.

Example 4 — Top longhand only

When only the top needs inset, use the longhand alone: scroll-padding-top: 3rem;.

longhand-only.css
.scroll-panel {
  scroll-padding-top: 3rem;
}
Try It Yourself

How It Works

Equivalent to scroll-padding: 3rem 0 0 0; when only the top matters.

scroll-padding-top in the family

scroll-padding-top is the top longhand of scroll-padding. For the opposite side, see scroll-padding-bottom.

shorthand-equivalent.css
/* These are equivalent when only the top matters */
.a { scroll-padding-top: 2rem; }
.b { scroll-padding: 2rem 0 0 0; }

🧠 How scroll-padding-top Works

1

Scroll container is configured

A scroll box with scroll-padding-top defines top inset for its scrollport.

Container
2

Top edge insets

The browser shrinks the effective snap area away from the container’s top edge.

Inset
3

Content scrolls into place

Snapped or scrolled content lands inside the inset scrollport at the top.

Position
=

Comfortable top stops

Opening content no longer feels cramped against the scrollport top.

Browser Compatibility

The scroll-padding-top 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 padding · Modern support

Reliable top support

Current Chrome, Firefox, Safari, Edge, and Opera support scroll-padding-top on scroll containers.

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 scroll snapping on mobile browsers to confirm top inset clears fixed headers or top UI.

scroll-padding-top property 97% supported

Bottom line: scroll-padding-top is safe to use in modern projects for scroll containers that need top inset.

Conclusion

The scroll-padding-top property is a valuable tool for enhancing the user experience with scroll snapping. By customizing the top padding, you can ensure content aligns properly within the viewport.

Adjusting the padding at the top of the scrollport helps prevent content from sitting under fixed headers and creates a smoother scrolling experience. Experiment with different padding values to see how this property can improve the usability of your web projects.

💡 Best Practices

✅ Do

  • Apply scroll-padding-top on the scroll container
  • Use it with vertical snap scrollers and overflow panels
  • Match inset to fixed header or top toolbar height
  • Test first-panel snap behavior on mobile
  • Prefer scroll-padding-block-start when you need logical block-axis inset

❌ Don’t

  • Confuse it with padding-top layout spacing
  • Set it on snap targets instead of the scroll container
  • Use huge percentages without testing on small screens
  • Forget bottom inset when last panels need space too

Key Takeaways

Knowledge Unlocked

Five things to remember about scroll-padding-top

Use these points when insetting top scroll containers.

5
Core concepts
02

top

Physical edge.

Axis
03

longhand

One side.

Detail
04

container

Scroll box.

Scope
05

snap

First panels.

Use case
🔄 06

padding

Four sides.

Companion

❓ Frequently Asked Questions

scroll-padding-top insets the scrollport at the top edge of a scroll container. It creates space so scrolled or snapped content does not sit flush against the top of the viewport or overflow box.
scroll-padding-top always targets the physical top edge. scroll-padding-block-start is logical and follows the block axis, which may map differently in vertical writing modes.
scroll-padding is a shorthand for all four sides. scroll-padding-top sets only the top inset of the scrollport.
The default value is auto, meaning the browser applies no extra top inset unless you specify a length, percentage, or other value.
Use it on scroll containers when top content should not sit under fixed headers, browser chrome, or the container edge, such as for first snap panels or vertical overflow scroll boxes.

Practice in the Live Editor

Open the HTML editor and try scroll-padding-top: 20px on a scroll container.

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