CSS scroll-padding-inline-start Property
The CSS scroll-padding-inline-start property defines an inset from the logical inline-start edge of a scroll container's scrollport for scroll alignment.
This property adjusts the optimal viewing region used during scroll snapping and other scrolling operations. Because it follows the writing mode and text direction, it can provide consistent alignment for left-to-right, right-to-left, and vertical writing systems without relying on fixed physical edges.
scroll-padding-inline-start Syntax
The scroll-padding-inline-start property accepts one non-negative CSS length, percentage, or the auto keyword.
Basic Syntax
selector {
scroll-padding-inline-start: 40px;
}
Available Values
.container {
scroll-padding-inline-start: 0;
}
.container {
scroll-padding-inline-start: 20px;
}
.container {
scroll-padding-inline-start: 3rem;
}
.container {
scroll-padding-inline-start: 1.5em;
}
.container {
scroll-padding-inline-start: 10%;
}
.container {
scroll-padding-inline-start: auto;
}
.container {
scroll-padding-inline-start: calc(2rem + 10px);
}
CSS-Wide Keywords
.container {
scroll-padding-inline-start: initial;
}
.container {
scroll-padding-inline-start: inherit;
}
.container {
scroll-padding-inline-start: unset;
}
.container {
scroll-padding-inline-start: revert;
}
.container {
scroll-padding-inline-start: revert-layer;
}
Negative values are invalid. This longhand property accepts one value, while the scroll-padding-inline shorthand accepts one or two values.
Property Values
| Value | Description |
|---|---|
<length> |
Sets a non-negative inset using a CSS length such as px, rem, or em. |
<percentage> |
Sets an inset relative to the scrollport's dimension along the inline axis. |
auto |
Allows the browser to determine an appropriate inset, typically zero. |
0 |
Specifies no additional inline-start scroll padding. |
calc() |
Calculates a non-negative length or percentage-based inset. |
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 inline-axis dimension |
| Negative values | Not accepted |
| Logical edge | Inline-start |
| Shorthand | scroll-padding-inline |
Valid Values
.container {
scroll-padding-inline-start: 50px;
}
.container {
scroll-padding-inline-start: 15%;
}
.container {
scroll-padding-inline-start: 4rem;
}
.container {
scroll-padding-inline-start: auto;
}
.container {
scroll-padding-inline-start: calc(2rem + 12px);
}
Invalid Values
.container {
scroll-padding-inline-start: -20px;
}
.container {
scroll-padding-inline-start: 10px 20px;
}
.container {
scroll-padding-inline-start: smooth;
}
.container {
scroll-padding-inline-start: normal;
}
.container {
scroll-padding-inline-start: 2s;
}
Negative lengths, multiple values, unrelated keywords, and time units are invalid.
How It Works
The scroll-padding-inline-start property establishes an inset from the logical inline-start edge of the scrollport. This adjusts the optimal viewing region used when aligning scroll targets.
When a target is aligned toward inline-start, the browser can position it inward from that edge rather than directly against the scrollport boundary.
Default Inline-Start Scroll Padding
.container {
scroll-padding-inline-start: auto;
}
The browser determines the inset. In most cases, the effective value is zero.
Fixed Inline-Start Inset
.container {
scroll-padding-inline-start: 60px;
}
The optimal viewing region begins 60 pixels inward from the logical inline-start edge.
Percentage-Based Inset
.container {
scroll-padding-inline-start: 10%;
}
In horizontal writing, the inset is calculated as 10% of the scrollport's width. In vertical writing, it is based on the scrollport's height.
Relative Lengths
.container {
scroll-padding-inline-start: 3rem;
}
Relative units allow the inset to scale with font-size settings.
No Layout Changes
Scroll padding does not add physical space to the container or move its child elements. Unlike padding-inline-start, it affects scroll alignment rather than normal layout.
Available Scroll Range
The browser may not achieve the requested alignment if the scroll container does not have enough available scroll range.
Writing Modes and Text Direction
The physical edge controlled by scroll-padding-inline-start depends on the scroll container's writing-mode and direction properties.
Inline-Start Edge Mapping
| Writing Mode | Direction | Inline-Start Edge |
|---|---|---|
horizontal-tb |
ltr |
Left |
horizontal-tb |
rtl |
Right |
vertical-rl |
ltr |
Top |
vertical-rl |
rtl |
Bottom |
vertical-lr |
ltr |
Top |
vertical-lr |
rtl |
Bottom |
Left-to-Right Horizontal Writing
.container {
writing-mode: horizontal-tb;
direction: ltr;
scroll-padding-inline-start: 50px;
}
The 50-pixel inset applies to the physical left edge.
Right-to-Left Horizontal Writing
.container {
writing-mode: horizontal-tb;
direction: rtl;
scroll-padding-inline-start: 50px;
}
The 50-pixel inset applies to the physical right edge.
Vertical Writing
.container {
writing-mode: vertical-rl;
direction: ltr;
scroll-padding-inline-start: 50px;
}
The inset applies to the physical top edge because inline progression runs from top to bottom.
Vertical Right-to-Left Direction
.container {
writing-mode: vertical-rl;
direction: rtl;
scroll-padding-inline-start: 50px;
}
The inset applies to the physical bottom edge because the inline direction is reversed.
Why Logical Properties Matter
Logical scroll padding adapts to different writing systems without requiring separate physical edge declarations for each direction.
Using scroll-padding-inline-start With Scroll Snap
The scroll-padding-inline-start property is useful when scroll snap targets should align inward from the logical inline-start edge.
Horizontal Scroll Snap
.scroll-container {
display: flex;
gap: 16px;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-padding-inline-start: 50px;
}
.scroll-container .item {
flex: 0 0 220px;
scroll-snap-align: start;
}
In left-to-right horizontal writing, items can snap 50 pixels inward from the left edge instead of aligning directly against it.
Different Start and End Insets
.scroll-container {
scroll-padding-inline-start: 60px;
scroll-padding-inline-end: 20px;
}
The optimal viewing region begins 60 pixels inward from inline-start and ends 20 pixels before inline-end.
Start Alignment
.scroll-container {
scroll-padding-inline-start: 40px;
}
.scroll-container .item {
scroll-snap-align: start;
}
Start-aligned items can snap inward from the inline-start edge.
Combining Scroll Padding and Scroll Margin
.scroll-container {
scroll-padding-inline-start: 40px;
}
.scroll-container .featured {
scroll-margin-inline-start: 20px;
scroll-snap-align: start;
}
For start alignment, these values can produce a combined 60-pixel offset between the featured item's inline-start border edge and the corresponding scrollport edge.
Important Consideration
Scroll padding does not enable snapping by itself. The container requires scroll-snap-type, and targets require scroll-snap-align.
Horizontal Carousels
Horizontal carousels often need alignment spacing at the beginning of the scrolling area. The scroll-padding-inline-start property can provide that spacing without changing normal layout.
Basic Carousel
.carousel {
display: flex;
gap: 16px;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-padding-inline-start: 40px;
}
.carousel .slide {
flex: 0 0 250px;
scroll-snap-align: start;
}
Slides can snap inward from the inline-start edge, leaving a 40-pixel alignment inset.
Adding Layout Space at the Start
.carousel {
display: flex;
gap: 16px;
overflow-x: auto;
padding-inline-start: 40px;
scroll-padding-inline-start: 40px;
scroll-snap-type: x mandatory;
}
Layout padding creates actual space before the carousel content, while scroll padding establishes the intended alignment inset. Using both can help the first slide align consistently.
Responsive Inline-Start Insets
.carousel {
scroll-padding-inline-start: 16px;
}
@media (min-width: 768px) {
.carousel {
scroll-padding-inline-start: 48px;
}
}
The carousel uses a smaller alignment inset on narrow screens and a larger inset on wider screens.
Right-to-Left Carousels
.carousel {
direction: rtl;
scroll-padding-inline-start: 40px;
}
In right-to-left horizontal writing, inline-start corresponds to the physical right edge.
Important Consideration
Scroll padding does not guarantee additional scroll range at the beginning of a carousel. Layout padding or another spacing technique may be necessary to achieve the desired alignment for the first item.
Programmatic Scrolling
JavaScript scrolling methods can use the optimal viewing region established by scroll-padding-inline-start when aligning a target.
Using scrollIntoView()
.scroll-container {
scroll-padding-inline-start: 60px;
}
document.querySelector(".target").scrollIntoView({
behavior: "smooth",
inline: "start",
block: "nearest"
});
In left-to-right horizontal writing, the target can align approximately 60 pixels inward from the left edge, provided sufficient scroll range is available.
Using Nearest Alignment
document.querySelector(".target").scrollIntoView({
behavior: "smooth",
inline: "nearest",
block: "nearest"
});
Nearest alignment minimizes scrolling rather than forcing inline-start alignment, so the resulting position may differ.
Respecting Reduced Motion
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
document.querySelector(".target").scrollIntoView({
behavior: reduceMotion ? "instant" : "smooth",
inline: "start",
block: "nearest"
});
Consider reduced-motion preferences when using animated scrolling.
Important Consideration
Scroll padding influences target alignment. It does not control scrolling speed, animation timing, or keyboard focus.
Using the scroll-padding-inline Shorthand
The scroll-padding-inline shorthand sets scroll padding insets for both logical inline edges.
One Value
.container {
scroll-padding-inline: 30px;
}
Both inline-start and inline-end receive 30 pixels.
Two Values
.container {
scroll-padding-inline: 60px 20px;
}
Inline-start receives 60 pixels, and inline-end receives 20 pixels.
Equivalent Longhand Declarations
.container {
scroll-padding-inline-start: 60px;
scroll-padding-inline-end: 20px;
}
These declarations produce the same logical insets as the two-value shorthand.
Overriding Inline-Start
.container {
scroll-padding-inline: 20px;
scroll-padding-inline-start: 60px;
}
The inline-start inset becomes 60 pixels, while inline-end remains 20 pixels.
Declaration Order
.container {
scroll-padding-inline-start: 60px;
scroll-padding-inline: 20px;
}
The later shorthand resets both inline insets to 20 pixels.
Using the Four-Edge Shorthand
.container {
scroll-padding: 20px;
scroll-padding-inline-start: 60px;
}
The physical edges initially receive 20 pixels. The later logical longhand changes the edge corresponding to inline-start to 60 pixels.
Logical Versus Physical Scroll Padding
Logical scroll padding follows the writing mode and text direction. Physical scroll padding always refers to fixed top, right, bottom, or left edges.
| Property | Edge |
|---|---|
scroll-padding-inline-start |
Logical inline-start |
scroll-padding-inline-end |
Logical inline-end |
scroll-padding-block-start |
Logical block-start |
scroll-padding-block-end |
Logical block-end |
scroll-padding-left |
Physical left |
scroll-padding-right |
Physical right |
scroll-padding-top |
Physical top |
scroll-padding-bottom |
Physical bottom |
Physical Left Inset
.container {
scroll-padding-left: 50px;
}
The inset always applies to the physical left edge.
Logical Inline-Start Inset
.container {
scroll-padding-inline-start: 50px;
}
The inset follows inline-start, which may be left, right, top, or bottom.
Overlapping Declarations
.container {
direction: ltr;
scroll-padding-left: 20px;
scroll-padding-inline-start: 60px;
}
In left-to-right horizontal writing, both declarations affect the left edge. With equal specificity and importance, the later declaration takes precedence.
Choosing the Appropriate Property
Use scroll-padding-inline-start when the inset should follow the writing direction. Use a physical property when alignment must remain tied to a particular physical edge.
scroll-padding-inline-start Versus scroll-margin-inline-start
Both properties influence scroll alignment at the logical inline-start edge, but they apply to different elements.
| Property | Applied To | Purpose |
|---|---|---|
scroll-padding-inline-start |
Scroll container | Defines an inset from the inline-start edge of the optimal viewing region. |
scroll-margin-inline-start |
Scroll target | Expands or contracts the target's scroll alignment area at its inline-start edge. |
Container-Side Scroll Padding
.scroll-container {
scroll-padding-inline-start: 40px;
}
The container provides a consistent inline-start alignment inset for its scroll targets.
Target-Side Scroll Margin
.scroll-container .featured {
scroll-margin-inline-start: 20px;
}
The featured target receives additional inline-start scroll alignment space.
Combining Both Properties
.scroll-container {
scroll-padding-inline-start: 40px;
}
.scroll-container .featured {
scroll-margin-inline-start: 20px;
}
For inline-start alignment, these values can produce a combined 60-pixel offset between the target's inline-start border edge and the corresponding scrollport 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-inline-start Example
This interactive example compares two horizontal scrolling panels. The second panel uses scroll-padding-inline-start: 50px to align the selected target farther from the left edge in a left-to-right layout.
HTML Example
<div class="scroll-inline-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 Inline-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-inline-start-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
gap: 20px;
}
.scroll-inline-start-demo .scroll-panel {
display: flex;
gap: 10px;
overflow-x: auto;
padding: 10px;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
scroll-snap-type: x mandatory;
}
.scroll-inline-start-demo .item {
flex: 0 0 110px;
padding: 25px 10px;
text-align: center;
background-color: #e2e8f0;
scroll-snap-align: start;
}
.scroll-inline-start-demo .target {
background-color: #bfdbfe;
border: 2px solid #2563eb;
}
.scroll-inline-start-demo .with-padding .scroll-panel {
scroll-padding-inline-start: 50px;
}
.scroll-inline-start-demo button {
margin-top: 10px;
padding: 8px 12px;
cursor: pointer;
}
JavaScript Example
document.querySelectorAll(".scroll-inline-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",
inline: "start",
block: "nearest"
});
});
});
Without Scroll Padding
With Inline-Start Scroll Padding
Click each button to bring the target toward the inline-start edge. In the second panel, the 50-pixel scroll padding moves the requested start alignment inward from the left edge.
Increasing Inline-Start Scroll Padding
.scroll-inline-start-demo .with-padding .scroll-panel {
scroll-padding-inline-start: 80px;
}
The inline-start alignment inset increases to 80 pixels.
Removing Inline-Start Scroll Padding
.scroll-inline-start-demo .with-padding .scroll-panel {
scroll-padding-inline-start: 0;
}
The additional inline-start alignment inset is removed.
Browser Compatibility Note
The final 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
Inline-start scroll padding can help keep scroll targets visible when interface elements or overlays occupy part of the scrolling area.
Avoid Obscured Content
Use an appropriate inline-start inset when controls or overlays could cover aligned content.
Maintain Keyboard Accessibility
Ensure carousel controls and other scrolling controls are keyboard accessible and have visible focus indicators.
Consider Focus Management
Programmatic scrolling does not automatically move keyboard focus. 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 Right-to-Left Layouts
Logical scroll padding follows the inline-start edge when text direction changes, reducing the need for separate physical edge rules.
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-inline-start: -20px;
}
Negative values are invalid.
Providing Multiple Values
.container {
scroll-padding-inline-start: 10px 20px;
}
This longhand property accepts only one value.
Assuming Inline-Start Always Means Left
Inline-start is the left edge in left-to-right horizontal writing, but it can be right, top, or bottom in other writing modes.
Confusing Scroll Padding With Layout Padding
scroll-padding-inline-start affects scroll alignment, while padding-inline-start adds normal layout spacing.
Applying Scroll Padding to a Target
Apply scroll-padding-inline-start to the scroll container. Use scroll-margin-inline-start on individual targets.
Expecting Automatic Scroll Snapping
The property does not enable scroll snapping by itself.
Ignoring Declaration Order
A later scroll-padding-inline or scroll-padding shorthand can override an earlier inline-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.
Expecting Extra Content Space
Scroll padding does not extend the scrollable content area. Additional layout spacing may be required for edge items.
Important Considerations
Keep the following points in mind when using scroll-padding-inline-start:
- It defines a scroll alignment inset at the logical inline-start edge.
- It is a longhand of
scroll-padding-inline. - Its initial value is
auto, and it is not inherited. - It accepts one non-negative length, percentage, or
autovalue. - Negative values are invalid.
- Percentages are relative to the scrollport's inline-axis dimension.
- The physical edge depends on writing mode and text direction.
- It does not change normal layout spacing or element dimensions.
- It can influence scroll snapping and programmatic scrolling.
- It is useful for horizontal carousels and right-to-left interfaces.
- It does not create a scroll container or enable scroll snapping.
- Use
scroll-padding-inline-endfor the opposite logical inline edge. - Use
scroll-padding-block-startfor the logical block-start edge. - Use
scroll-margin-inline-startwhen individual targets need an inline-start alignment offset. - Available scroll range may limit the final alignment position.
- Test scrolling behavior across writing modes, directions, and viewport sizes.
Browser Support
The CSS scroll-padding-inline-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-inline-start.
When unsupported, scrolling generally remains functional, but the requested logical alignment inset may not be applied.
Specifications
The scroll-padding-inline-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.
