Logical Properties, Overflow & Scroll Snap
Write internationalization-ready spacing with margin-inline and padding-block, manage overflow cleanly, and build silky horizontal carousels with CSS Scroll Snap.
What you'll learn
- Use logical shorthands (margin-inline, padding-block) instead of physical left/right/top/bottom
- Handle overflowing content safely with overflow: auto and overflow: clip
- Create touch-friendly snapping carousels with scroll-snap-type and scroll-snap-align
Logical Properties
Instead of physical directions (margin-left, margin-right), modern CSS uses flow-relative logical properties:
| Physical | Logical Equivalent | Benefit |
|---|---|---|
margin-left + margin-right | margin-inline | One shorthand (margin-inline: auto centers horizontally!) |
padding-top + padding-bottom | padding-block | Adapts automatically to right-to-left (RTL) & vertical writing modes |
border-left | border-inline-start | Flips to the right automatically in Arabic/Hebrew (dir="rtl") |
Zero-JS Carousels with Scroll Snap
Add just two properties to turn any horizontal scrolling row into a crisp, touch-friendly snapping carousel:
- Container:
scroll-snap-type: x mandatory; - Slides:
scroll-snap-align: start;
Fill-in-the-Blank Exercise
Logical Centering & Scroll Snap
Center a container horizontally with a logical property and snap carousel slides cleanly.
.container {
max-width: 60rem;
: auto;
}
.carousel {
overflow-x: auto;
scroll-snap-type: x ;
}Try It Yourself
Scroll horizontally through the cards below and feel them snap cleanly into place!
Check Your Understanding
1. What is the logical-property equivalent of setting both margin-left: auto and margin-right: auto?
Finished this lesson?
Your progress is saved locally in your browser, no account needed.