CSS Academy · Lesson

repeat() and minmax() in Grid

Generate multiple grid tracks and define flexible size ranges using repeat() and minmax().

Lesson 3 of 413 steps

repeat() and minmax() in Grid is a free CSS Academy lesson on CoddyKit. This is lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, and your progress syncs across the web and the CoddyKit app. The CSS Academy course includes 4 lessons in total.

repeat() in Grid Context

repeat(count, track-size) is a CSS Grid function that generates multiple track definitions without repetition. It works inside grid-template-columns and grid-template-rows.

repeat() with Fixed Count

Create 4 equal columns:

  <div class="grid">
    <div>1</div><div>2</div><div>3</div><div>4</div>
  </div>

repeat() with Pattern

Repeat a pattern of tracks:

  <div class="striped-grid">
    <div>A</div><div>B</div><div>C</div><div>D</div><div>E</div><div>F</div>
  </div>

minmax() Inside Tracks

minmax(min, max) defines a track size range:

  <div class="grid">
    <div>1</div><div>2</div><div>3</div>
  </div>

auto-fit with minmax()

The responsive grid recipe:

  <div class="cards">
    <div>Card A</div><div>Card B</div>
  </div>

minmax(min-content, max-content)

Track sizes can use intrinsic sizing keywords:

  <div class="labels">
    <div>Label</div><div>Value</div>
  </div>

minmax() in Rows

Use minmax() for rows to allow content-driven height with a minimum:

  <div class="gallery"><div>1</div><div>2</div></div>

fit-content() for Columns

fit-content(max) makes a track as wide as its content up to a specified maximum — like max-content but capped:

  <div class="layout"><div>Sidebar</div><div>Main</div></div>

Combining repeat() and Named Lines

Repeat named lines to address individual columns by name:

  <div class="grid">
    <div>1</div><div>2</div><div>3</div><div>4</div>
  </div>

auto-fill with minmax for Fixed Items

When items should not stretch beyond their natural size:

  <div class="gallery">
    <div>1</div><div>2</div><div>3</div>
  </div>

fr vs Percentages in Grid

Unlike percentages, fr units automatically account for gap space. repeat(3, 1fr) with gap: 24px gives 3 truly equal columns. Percentages would need calc() to subtract gap.

Quick Check

What does repeat(3, minmax(100px, 1fr)) define?

Recap

repeat(count, track) generates multiple tracks without repetition. minmax(min, max) defines flexible track size ranges. The repeat(auto-fit, minmax(280px, 1fr)) pattern is the most powerful responsive grid — zero media queries, automatically responsive columns. Use fit-content(max) for content-aware sidebar columns.

Free to start

Learn CSS with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
40
Lessons
159

Frequently Asked Questions

Is the “repeat() and minmax() in Grid” lesson free?

Yes — the full text of “repeat() and minmax() in Grid” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO. The CSS Academy course includes 4 lessons in total.

What will I learn in “repeat() and minmax() in Grid”?

Generate multiple grid tracks and define flexible size ranges using repeat() and minmax(). You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.

How long does the “repeat() and minmax() in Grid” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. calc() for Dynamic Calculations
  2. min() max() and clamp() for Fluid Values
  3. repeat() and minmax() in Grid
  4. color-mix() and relative color syntax
← Back to CSS Academy