liveBook · Manning

Auto-fit

A CSS Grid repeat() keyword that creates as many repeated tracks as fit within the available space and collapses empty tracks.

How 2 Manning books explain it

CSS in Depth, Second Edition

Auto-fill and auto-fit are CSS Grid track-repetition keywords that determine how many tracks are generated to fit available space.

How it is used
Builds responsive card and portfolio grids whose column count follows available space and item constraints.
How deep it goes
Explains repeat(), minmax(), flexible track sizing, empty-track behavior, and breakpoint use without detailing browser layout internals.
Examples
Demonstrates portfolio photographs and chicken cards arranged in adaptive grids.
What you can do after
Apply it via CSS Grid to build adaptive columns without manually specifying each viewport’s column count.

Read how CSS in Depth, Second Edition explains auto-fit →

Math for Web Design

auto-fit is a CSS Grid repeat() keyword that creates fitting tracks and collapses empty tracks so available space can be redistributed.

How it is used
Builds responsive Grid layouts that adapt track counts and redistribute space without querying viewport width.
How deep it goes
Explains repetition math, gap subtraction, empty-track collapse, and flexible redistribution through runnable CSS examples.
Examples
Demonstrates two cards in an 850px container, contrasting 212.5px auto-fill tracks with 425px auto-fit tracks.
What you can do after
Build responsive card grids with repeat(auto-fit, minmax(...)) and choose whether empty tracks collapse or remain.

Read how Math for Web Design explains auto-fit →

What to know first

Related concepts

Questions about auto-fit

What is auto-fit?

A CSS Grid repeat() keyword that creates as many repeated tracks as fit within the available space and collapses empty tracks.

Which Manning books explain auto-fit?

CSS in Depth, Second Edition and Math for Web Design.

What should I know before learning auto-fit?

Manning books that teach auto-fit usually introduce flexbox and media query first.

What is the difference between auto-fit and auto-fill?

A CSS Grid repeat() keyword that creates as many repeated tracks as fit within the available space and collapses empty tracks. A CSS Grid repeat() keyword that creates as many repeated tracks as fit within the available space, retaining empty tracks.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.