SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Welcome to CSS
Grid FundamentalsGrid TracksGrid Placement and Layout DecisionsImplicit GridsFlexible GridsGrid AlignmentGrid or Flexbox Placing items on a grid
CSS Grid

Implicit Grids

Understand automatic placement and implicit tracks.

Grid can add rows or columns when more items need space. These are implicit tracks, and they let your layout grow without a set row count.

Let automatic placement add rows

.list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 4rem;
  grid-auto-rows: minmax(6rem, auto);
  gap: 1rem;
}

For these items, default row-wise placement fills two cells in the first row, two in the next, then one in a third row.

  • The first row is explicit and uses 4rem.
  • The second and third rows are implicit and use minmax(6rem, auto).
  • Additional items can create more implicit rows.

grid-auto-rows sizes automatically created rows; it does not replace the explicit row template. An auto maximum lets these implicit rows grow when their content needs more than the minimum.

Predict the added rows

In the example above, a sixth article is added. Does it need a fourth row, and what sizes its row?

Check your reasoning

It fills the second cell of the existing third row. That row is implicit and uses grid-auto-rows: minmax(6rem, auto).

If a seventh article is added, identify the new row and the property that sizes it.

Check your reasoning

It creates a fourth row, also sized by grid-auto-rows. The first row alone uses the explicit template.

Understand the placement direction

The initial grid-auto-flow value is row. It fills rows in turn and creates more rows as needed. For ordinary items without placement or order overrides, the sequence follows source order.

You can instead fill columns:

.columns {
  display: grid;
  grid-template-rows: repeat(2, 5rem);
  grid-auto-flow: column;
  grid-auto-columns: 10rem;
  gap: 1rem;
}

Two items occupy the first column before placement advances to the next. grid-auto-columns gives the implicit columns a 10rem size. A long collection can therefore become wider than its container; column flow is not automatic horizontal scrolling.

Recognize gaps left by spans

Suppose there are three columns and only the last cell of a row is free. An item spanning two columns must move to the following row. By default, the placement cursor continues forward, so a later single-cell item leaves the earlier hole open.

.packed {
  grid-auto-flow: row dense;
}

dense lets the browser fill earlier gaps with later items that fit. This can change their visual order while leaving the HTML and usual Tab order unchanged. Check that the result still makes sense.

A and B each span two columns. With row placement C follows B in the second row. With row dense, C fills the empty cell beside A in the first row, even though it still follows B in the HTML.

Inspect unexpected implicit tracks

An item placed beyond the rows or columns you defined can create implicit tracks too. When extra columns appear unexpectedly, inspect item line numbers and spans as well as the template.

Use a grid overlay to distinguish explicit boundaries from added tracks.

Key Takeaways

  • Implicit tracks: Appear when placement needs tracks beyond the explicit grid.
  • Automatic sizing: grid-auto-rows and grid-auto-columns size those added tracks.
  • Flow: Row flow adds rows; column flow adds columns.
  • Dense packing: Can fill earlier holes while changing visual order.

Try it yourself

Try it yourself

Size added rows

HTML + CSS

Loading code editor…

Live preview

Updating…

Final output

No comparison yetChecks after 3s without edits
Loading your draft…

How is this lesson?

Previous lessonGrid Placement and Layout DecisionsNext lessonFlexible Grids
Edit on GitHubReport on GitHub
On this page
%

On this page

Let automatic placement add rowsPredict the added rowsUnderstand the placement directionRecognize gaps left by spansInspect unexpected implicit tracksKey TakeawaysTry it yourself