The logical properties scroll-padding-inline and scroll-padding-block define the βsafe scroll areaβ inside a scroll container along the inline and block axes. They work exactly like scroll-padding-left/right/top/bottom, but adapt to writing-mode and direction automatically.
Note
β Often used with scroll-snap-type and scroll-snap-align
β Does NOT change layout β only scroll snapping behavior
π¦ 1. Understanding Logical Directions
| Logical Property | Maps to (Left-to-Right) | Maps to (Right-to-Left) |
|---|---|---|
| scroll-padding-inline-start | left | right |
| scroll-padding-inline-end | right | left |
| scroll-padding-block-start | top | top (same) |
| scroll-padding-block-end | bottom | bottom (same) |
Logical scroll padding allows snapping to work correctly in RTL, LTR, and vertical writing.
π 2. Syntax
scroll-padding-inline
scroll-padding-inline: <length> | <percentage>;scroll-padding-block
scroll-padding-block: <length> | <percentage>;π¨ 3. Basic Examples
β¨ A. Horizontal Slider Using scroll-padding-inline
Horizontal snap layout
.slider {
display: flex;
overflow-x: auto;
scroll-snap-type: inline mandatory;
scroll-padding-inline: 20px; /* space on both inline edges */
}
.slide {
scroll-snap-align: start;
}Ensures the first and last slides do not stick to the edges.
β¨ B. Vertical Sections Using scroll-padding-block
Vertical snap layout
.sections {
overflow-y: auto;
height: 100vh;
scroll-snap-type: block mandatory;
scroll-padding-block: 80px; /* extra room on top & bottom */
}
.section {
scroll-snap-align: start;
}Useful when you have sticky headers that would otherwise hide the section title.
π¨ 4. Inline Start / End (Precise Control)
inline start / end
.carousel {
scroll-snap-type: inline mandatory;
scroll-padding-inline-start: 40px;
scroll-padding-inline-end: 10px;
}Note
π¨ 5. Block Start / End Example
block start/end
.page {
scroll-snap-type: block mandatory;
scroll-padding-block-start: 100px; /* room for sticky header */
scroll-padding-block-end: 30px;
}π 6. Combining scroll-padding-inline + scroll-padding-block
Combined logical scroll padding
.container {
scroll-snap-type: both mandatory;
scroll-padding-inline: 20px;
scroll-padding-block: 40px;
}This creates a balanced βsnap-safe zoneβ on all logical sides.
π§ͺ Real-World Use Cases
1οΈβ£ Multi-language Carousel (LTR + RTL)
RTL-ready carousel
.carousel {
scroll-snap-type: inline mandatory;
scroll-padding-inline: 24px;
}Behaves correctly in Arabic, Hebrew, Japanese, and English layouts.
2οΈβ£ Documentation Reader with Sticky Header
Docs layout
.doc-viewer {
height: 100vh;
overflow-y: scroll;
scroll-snap-type: block mandatory;
scroll-padding-block-start: 80px; /* header height */
}3οΈβ£ Product Card Grid with 2D Snapping
2D snap grid
.grid-scroll {
scroll-snap-type: both proximity;
scroll-padding-inline: 16px;
scroll-padding-block: 16px;
}β οΈ Common Mistakes
- β Applying these properties on children instead of the scroll container
- β Forgetting to add scroll-snap-type to enable snapping
- β Expecting them to add layout padding (they donβt β scroll only!)
- β Using left/right/top/bottom in multilingual sites instead of logical properties
Note
π₯ Summary
scroll-padding-inline and scroll-padding-block offer powerful, writing-modeβaware control for scroll snapping interfaces. They ensure perfect spacing regardless of language direction or layout orientation.