Skip to content
Guest
Learn CSS · Course Syllabus Show lessons
Responsive & Modern Selectors · 8 min read · Beginner

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:

PhysicalLogical EquivalentBenefit
margin-left + margin-rightmargin-inlineOne shorthand (margin-inline: auto centers horizontally!)
padding-top + padding-bottompadding-blockAdapts automatically to right-to-left (RTL) & vertical writing modes
border-leftborder-inline-startFlips 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!

CSS Scroll Snap Carousel
Live Result

Check Your Understanding

Score: 0 / 1

1. What is the logical-property equivalent of setting both margin-left: auto and margin-right: auto?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind