Skip to the page

Layout systems · core

Grid, and grid vs flexbox

Grid lays items out in two dimensions with explicit tracks (grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))), while flexbox is content-first in one dimension; use grid for page and card layouts, flexbox for rows of things.

The notes

What you must know

  • fr shares free space; minmax(min, max); repeat(auto-fill vs auto-fit, ...) — auto-fit collapses empty tracks so items stretch.
  • grid-template-areas names regions for readable page layouts.
  • subgrid lets children align to the parent grid (supported in all modern browsers).
  • Rule of thumb: grid when you know the layout (rows and columns), flex when content decides.

The red pen

Common traps: mistake → fix

  • Mistake: "grid replaces flexbox"

    Fix: they solve different problems and are used together.

Easy to hard

Questions interviewers ask, easy to hard

  1. Grid vs flexbox: when do you use which?
  2. Build a responsive card grid without media queries.
  3. auto-fill vs auto-fit?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview