CSS scroll-padding-block-start Property

The CSS scroll-padding-block-start property defines a scroll alignment inset at the logical block-start edge of a scroll container.

The physical edge depends on the element's writing mode. In horizontal writing, block-start corresponds to the top edge. In vertical writing, it corresponds to the left or right edge. This property helps keep scroll targets visible when scrolling or navigating to content without changing normal layout spacing.

scroll-padding-block-start Syntax

The scroll-padding-block-start property accepts a single non-negative CSS length, percentage, or the auto keyword.

Basic Syntax

selector {
  scroll-padding-block-start: 20px;
}

Available Values

.container {
  scroll-padding-block-start: 0;
}
.container {
  scroll-padding-block-start: 20px;
}
.container {
  scroll-padding-block-start: 2rem;
}
.container {
  scroll-padding-block-start: 1.5em;
}
.container {
  scroll-padding-block-start: 10%;
}
.container {
  scroll-padding-block-start: auto;
}
.container {
  scroll-padding-block-start: calc(3rem + 10px);
}

CSS-Wide Keywords

.container {
  scroll-padding-block-start: initial;
}
.container {
  scroll-padding-block-start: inherit;
}
.container {
  scroll-padding-block-start: unset;
}
.container {
  scroll-padding-block-start: revert;
}
.container {
  scroll-padding-block-start: revert-layer;
}

Negative values are invalid. The auto keyword allows the browser to determine an appropriate inset.

Property Values

Value Description
<length> Sets the block-start scroll padding using a non-negative CSS length such as px, rem, or em.
<percentage> Sets the inset as a percentage of the scrollport's dimension along the block axis.
auto Lets the browser determine an appropriate scroll padding inset. It generally resolves to zero unless another offset is appropriate.
0 Applies no additional block-start scroll padding.
calc() Calculates a valid non-negative length or percentage-based value.
initial Resets the property to its initial value of auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Scroll containers
Computed value As specified
Animation type By computed value type
Percentages Relative to the scrollport's block-axis dimension
Negative values Not accepted
Logical edge Block-start

Valid Values

.container {
  scroll-padding-block-start: 40px;
}
.container {
  scroll-padding-block-start: 10%;
}
.container {
  scroll-padding-block-start: 4rem;
}
.container {
  scroll-padding-block-start: auto;
}
.container {
  scroll-padding-block-start: calc(3rem + 10px);
}

Invalid Values

.container {
  scroll-padding-block-start: -10px;
}
.container {
  scroll-padding-block-start: 10px 20px;
}
.container {
  scroll-padding-block-start: smooth;
}
.container {
  scroll-padding-block-start: 2s;
}
.container {
  scroll-padding-block-start: normal;
}

This longhand property accepts only one non-negative length, percentage, or auto value. Multiple values, negative lengths, and scrolling behavior keywords are invalid.

How It Works

The scroll-padding-block-start property establishes an inset from the block-start edge of a scroll container's scrollport.

This inset defines part of the optimal viewing region used when the browser aligns scroll targets.

Default Block-Start Scroll Padding

.container {
  scroll-padding-block-start: auto;
}

The browser determines the inset. In most cases, the effective value is zero.

Fixed Block-Start Inset

.container {
  scroll-padding-block-start: 60px;
}

The optimal viewing region begins 60 pixels inward from the scrollport's block-start edge.

Percentage-Based Inset

.container {
  scroll-padding-block-start: 10%;
}

The percentage is calculated relative to the scrollport's block-axis dimension.

Relative Lengths

.container {
  scroll-padding-block-start: 4rem;
}

Relative units allow the inset to scale with font-size settings.

No Layout Changes

Unlike padding-block-start, scroll padding does not add layout space, move child elements, or change the container's dimensions.

Available Scroll Range

The browser may not achieve the requested alignment if the container cannot scroll far enough.

Writing Modes and Logical Edges

The physical edge controlled by scroll-padding-block-start depends on the scroll container's writing mode.

Logical Edge Mapping

Writing Mode Block-Start Edge
horizontal-tb Top
vertical-rl Right
vertical-lr Left
sideways-rl Right
sideways-lr Left

Horizontal Writing Mode

.container {
  writing-mode: horizontal-tb;
  scroll-padding-block-start: 60px;
}

The 60-pixel inset applies to the physical top edge.

Vertical Right-to-Left Writing Mode

.container {
  writing-mode: vertical-rl;
  scroll-padding-block-start: 60px;
}

The 60-pixel inset applies to the physical right edge.

Vertical Left-to-Right Writing Mode

.container {
  writing-mode: vertical-lr;
  scroll-padding-block-start: 60px;
}

The 60-pixel inset applies to the physical left edge.

Text Direction

Changing direction between ltr and rtl affects the inline axis, but it does not reverse block-start and block-end in these writing modes.

Why Logical Properties Matter

Logical properties allow scroll alignment to adapt to different writing systems without manually replacing top, right, bottom, or left declarations.

Using scroll-padding-block-start With Scroll Snap

The scroll-padding-block-start property is useful when scroll snap targets should align away from the block-start edge of a scrolling container.

Vertical Scroll Snap

.scroll-container {
  height: 300px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-block-start: 60px;
}
.scroll-container .item {
  min-height: 200px;
  scroll-snap-align: start;
}

In horizontal writing, items using scroll-snap-align: start can align 60 pixels below the scrollport's top edge.

Different Start and End Insets

.scroll-container {
  scroll-padding-block-start: 60px;
  scroll-padding-block-end: 20px;
}

The optimal viewing region has a 60-pixel block-start inset and a 20-pixel block-end inset.

Vertical Writing Mode

.scroll-container {
  writing-mode: vertical-rl;
  width: 300px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-block-start: 40px;
}
.scroll-container .item {
  scroll-snap-align: start;
}

In vertical-rl, the block-start edge is physically on the right. The scroll padding establishes a 40-pixel inset from that edge.

Combining With Scroll Margin

.scroll-container {
  scroll-padding-block-start: 40px;
}
.scroll-container .item {
  scroll-margin-block-start: 20px;
}

For block-start alignment, the two values can create a combined 60-pixel offset between the item's block-start border edge and the scrollport's block-start edge.

Important Consideration

Scroll padding does not enable scroll snapping. The container still requires scroll-snap-type, and the targets require scroll-snap-align.

Anchor Navigation and Sticky Headers

In horizontal writing, scroll-padding-block-start can prevent anchor targets from aligning beneath sticky or fixed headers.

Document Scroll Offset

html {
  scroll-padding-block-start: 80px;
}

For a document using horizontal-tb, this establishes an 80-pixel scroll alignment inset at the top of the viewport.

Anchor Navigation HTML

<nav aria-label="Page sections">
  <a href="#introduction">Introduction</a>
  <a href="#examples">Examples</a>
  <a href="#resources">Resources</a>
</nav>
<section id="introduction">
  <h2>Introduction</h2>
</section>
<section id="examples">
  <h2>Examples</h2>
</section>
<section id="resources">
  <h2>Resources</h2>
</section>

Using a Custom Property

:root {
  --header-height: 80px;
}
html {
  scroll-padding-block-start: calc(var(--header-height) + 16px);
}

The calculated inset accounts for the header height and adds 16 pixels of additional spacing.

Responsive Header Heights

html {
  scroll-padding-block-start: 90px;
}
@media (max-width: 767px) {
  html {
    scroll-padding-block-start: 60px;
  }
}

The inset changes to accommodate a shorter header on smaller screens.

Using Scroll Padding on a Nested Container

.sidebar-content {
  height: 300px;
  overflow-y: auto;
  scroll-padding-block-start: 50px;
}

Apply the property directly to a separately scrolling panel when its content needs a block-start alignment inset.

Important Consideration

For document scrolling, apply scroll padding to the root html element. For a nested scroll container, apply it to that container instead.

Programmatic Scrolling

JavaScript scrolling methods can use the optimal viewing region defined by scroll-padding-block-start when aligning a target.

Using scrollIntoView()

.scroll-container {
  scroll-padding-block-start: 60px;
}
document.querySelector(".target").scrollIntoView({
  behavior: "smooth",
  block: "start"
});

In horizontal writing, start alignment can position the target approximately 60 pixels below the scrollport's top edge, provided sufficient scroll range is available.

Using Nearest Alignment

document.querySelector(".target").scrollIntoView({
  behavior: "smooth",
  block: "nearest"
});

Nearest alignment minimizes scrolling rather than forcing block-start alignment, so the visible effect of the inset may differ.

Respecting Reduced Motion

const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
document.querySelector(".target").scrollIntoView({
  behavior: reduceMotion ? "instant" : "smooth",
  block: "start"
});

Consider reduced-motion preferences when using animated scrolling.

Important Consideration

The property controls scroll alignment spacing, not scroll animation, scrolling speed, or focus movement.

Using the scroll-padding-block Shorthand

The scroll-padding-block shorthand sets both block-start and block-end scroll padding.

One-Value Shorthand

.container {
  scroll-padding-block: 30px;
}

Both block-start and block-end receive 30 pixels.

Two-Value Shorthand

.container {
  scroll-padding-block: 60px 20px;
}

Block-start receives 60 pixels, and block-end receives 20 pixels.

Equivalent Longhand Declarations

.container {
  scroll-padding-block-start: 60px;
  scroll-padding-block-end: 20px;
}

Overriding Block-Start

.container {
  scroll-padding-block: 20px;
  scroll-padding-block-start: 60px;
}

The block-start inset becomes 60 pixels, while block-end remains 20 pixels.

Declaration Order

.container {
  scroll-padding-block-start: 60px;
  scroll-padding-block: 20px;
}

The later shorthand resets both block-axis insets to 20 pixels.

Combining Block and Inline Insets

.container {
  scroll-padding-block: 60px 20px;
  scroll-padding-inline: 30px;
}

The block axis uses different start and end insets, while both inline edges receive 30 pixels.

Logical Versus Physical Scroll Padding

The scroll-padding-block-start property follows the logical block-start edge, while physical scroll padding properties always refer to fixed physical edges.

Property Edge
scroll-padding-block-start Logical block-start
scroll-padding-block-end Logical block-end
scroll-padding-inline-start Logical inline-start
scroll-padding-top Physical top
scroll-padding-right Physical right
scroll-padding-left Physical left

Physical Top Scroll Padding

.container {
  scroll-padding-top: 60px;
}

The inset always applies to the physical top edge.

Logical Block-Start Scroll Padding

.container {
  scroll-padding-block-start: 60px;
}

The inset follows the block-start edge, which depends on writing mode.

Overlapping Declarations

.container {
  writing-mode: horizontal-tb;
  scroll-padding-top: 20px;
  scroll-padding-block-start: 60px;
}

Both declarations affect the physical top edge in horizontal writing mode. With equal specificity and importance, the later declaration takes precedence.

Choosing Between Logical and Physical Properties

Use logical properties when scroll alignment should adapt to writing mode. Use physical properties when the inset must remain on a specific top, right, bottom, or left edge.

scroll-padding-block-start Versus scroll-margin-block-start

Both properties influence alignment at the logical block-start edge, but they are applied to different elements.

Property Applied To Purpose
scroll-padding-block-start Scroll container Defines an inset from the block-start edge of the optimal viewing region.
scroll-margin-block-start Scroll target Expands or contracts the target's scroll alignment area at its block-start edge.

Container-Side Scroll Padding

.scroll-container {
  scroll-padding-block-start: 40px;
}

The container provides a consistent block-start alignment inset for its scroll targets.

Target-Side Scroll Margin

.scroll-container .featured {
  scroll-margin-block-start: 20px;
}

The featured target receives an additional block-start alignment area.

Combining Both Properties

.scroll-container {
  scroll-padding-block-start: 40px;
}
.scroll-container .featured {
  scroll-margin-block-start: 20px;
}

For block-start alignment, these values can create a combined 60-pixel offset between the target's block-start border edge and the scrollport's block-start edge.

Important Difference

Scroll padding accepts percentages and auto but not negative values. Scroll margin accepts negative lengths but not percentages or auto.

scroll-padding-block-start Example

This interactive example compares two vertically scrolling panels. The second panel applies a 50-pixel block-start inset, which corresponds to the top edge in horizontal writing mode.

HTML Example

<div class="scroll-block-start-demo">
  <div class="scroll-example">
    <h3>Without Scroll Padding</h3>
    <div class="scroll-panel">
      <div class="item">Item 1</div>
      <div class="item">Item 2</div>
      <div class="item target">Target</div>
      <div class="item">Item 4</div>
      <div class="item">Item 5</div>
      <div class="item">Item 6</div>
    </div>
    <button type="button">Scroll to Target</button>
  </div>
  <div class="scroll-example with-padding">
    <h3>With Block-Start Scroll Padding</h3>
    <div class="scroll-panel">
      <div class="item">Item 1</div>
      <div class="item">Item 2</div>
      <div class="item target">Target</div>
      <div class="item">Item 4</div>
      <div class="item">Item 5</div>
      <div class="item">Item 6</div>
    </div>
    <button type="button">Scroll to Target</button>
  </div>
</div>

CSS Example

.scroll-block-start-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 20px;
}
.scroll-block-start-demo .scroll-panel {
  height: 180px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  scroll-snap-type: y mandatory;
}
.scroll-block-start-demo .item {
  padding: 22px 10px;
  margin-bottom: 10px;
  text-align: center;
  background-color: #e2e8f0;
  scroll-snap-align: start;
}
.scroll-block-start-demo .target {
  background-color: #bfdbfe;
  border: 2px solid #2563eb;
}
.scroll-block-start-demo .with-padding .scroll-panel {
  scroll-padding-block-start: 50px;
}
.scroll-block-start-demo button {
  margin-top: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

JavaScript Example

document.querySelectorAll(".scroll-block-start-demo .scroll-example").forEach((example) => {
  const button = example.querySelector("button");
  const target = example.querySelector(".target");
  button.addEventListener("click", () => {
    target.scrollIntoView({
      behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth",
      block: "start",
      inline: "nearest"
    });
  });
});
Browser Result

Without Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

With Block-Start Scroll Padding

Item 1
Item 2
Target
Item 4
Item 5
Item 6

Click each button to bring the target toward the top of its panel. The second panel requests a 50-pixel inset from the top edge, so the target can align lower within the scrollport.

Increasing the Block-Start Inset

.scroll-block-start-demo .with-padding .scroll-panel {
  scroll-padding-block-start: 80px;
}

The block-start alignment inset increases to 80 pixels.

Removing the Block-Start Inset

.scroll-block-start-demo .with-padding .scroll-panel {
  scroll-padding-block-start: 0;
}

The additional block-start alignment inset is removed.

Browser Compatibility Note

The final scroll position depends on available scroll range and scroll snapping behavior. Targets near the beginning or end of the container may not reach the requested alignment.

Accessibility Considerations

Block-start scroll padding can improve the visibility of content when sticky headers or other interface elements overlap the beginning of a scrollport.

Keep Anchor Targets Visible

Use an appropriate block-start inset to prevent anchor targets from being obscured by sticky or fixed headers.

Maintain Keyboard Accessibility

Scrolling controls should remain keyboard accessible and display visible focus indicators.

Consider Focus Management

Programmatic scrolling does not automatically move keyboard focus to the target. Scripted navigation may require additional focus handling.

Respect Reduced Motion Preferences

The property does not animate scrolling. If smooth scrolling is used, respect prefers-reduced-motion.

Support Different Writing Modes

Logical scroll padding adapts to writing mode, helping maintain consistent alignment in horizontal and vertical text layouts.

Test Responsive Layouts

Verify scroll alignment at different viewport sizes, browser zoom levels, and text scaling settings.

Common Mistakes

Using Negative Values

.container {
  scroll-padding-block-start: -20px;
}

Negative values are invalid.

Providing Multiple Values

.container {
  scroll-padding-block-start: 10px 20px;
}

This longhand property accepts only one value.

Confusing Block-Start With Top

Block-start corresponds to the top edge in horizontal writing but can correspond to the right or left edge in vertical writing.

Confusing Scroll Padding With Layout Padding

scroll-padding-block-start affects scroll alignment, while padding-block-start affects normal layout spacing.

Applying the Property to a Scroll Target

Apply scroll-padding-block-start to the scroll container. Use scroll-margin-block-start on individual targets.

Expecting Automatic Scroll Snapping

The property does not enable scroll snapping by itself.

Ignoring Declaration Order

A later scroll-padding-block shorthand can override an earlier scroll-padding-block-start declaration.

Ignoring Physical and Logical Conflicts

Physical and logical scroll padding declarations may affect the same edge. The CSS cascade determines which declaration applies.

Ignoring Available Scroll Range

The browser may not achieve the requested alignment when the container cannot scroll far enough.

Important Considerations

Keep the following points in mind when using scroll-padding-block-start:

  • It defines a scroll alignment inset at the logical block-start edge.
  • It is a longhand of scroll-padding-block.
  • Its initial value is auto, and it is not inherited.
  • It accepts one non-negative length, percentage, or auto value.
  • Negative values are invalid.
  • Percentages are relative to the scrollport's block-axis dimension.
  • Its physical edge depends on the writing mode.
  • In horizontal writing, block-start corresponds to the top edge.
  • In vertical-rl, block-start corresponds to the right edge.
  • In vertical-lr, block-start corresponds to the left edge.
  • It does not change normal layout spacing or element dimensions.
  • It can influence scroll snapping, anchor navigation, and programmatic scrolling.
  • It is useful for scroll offsets beneath sticky or fixed headers.
  • It does not create a scroll container or enable scroll snapping.
  • Use scroll-padding-block-end for the opposite logical block edge.
  • Use scroll-margin-block-start when individual targets need a block-start alignment offset.
  • Available scroll range may limit the final alignment position.
  • Test scrolling behavior across writing modes, viewport sizes, and input methods.

Browser Support

The CSS scroll-padding-block-start property is supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.

Support in older browsers may be limited, particularly for logical scroll padding properties and vertical writing modes.

For current compatibility information, visit Can I Use? and search for scroll-padding-block-start.

When unsupported, scrolling generally remains functional, but the requested logical alignment inset may not be applied.

Specifications

The scroll-padding-block-start property is defined in CSS Scroll Snap Module Level 1.

CSS Scroll Snap Module Level 1

The specification defines how scroll padding establishes the optimal viewing region within a scrollport.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: scroll-padding-block-start