Skip to content

CSS Grid Vs Flexbox When To Use Which

Master CSS Grid Vs Flexbox When To Use Which with 202 free flashcards. Study using spaced repetition and focus mode for effective learning in Frontend.

🎓 202 cards ⏱️ ~101 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

One-line summary: when Grid vs Flexbox?

Show ▼

Grid: 2D layout (rows AND columns), known structure.
Flexbox: 1D layout (row OR column), content-driven.

Center a single element on the page — Grid or Flex?

Show ▼

Either works. display: grid; place-items: center; or display: flex; align-items: center; justify-content: center;

Make a sidebar + main layout with Grid?

Show ▼

grid-template-columns: 250px 1fr;

Same layout with Flex?

Show ▼

display:flex; with sidebar flex: 0 0 250px and main flex: 1.

Equal-height columns naturally?

Show ▼

Grid: rows stretch by default.
Flex: items stretch on the cross axis (align-items: stretch is default).

Holy Grail layout?

Show ▼

Grid: grid-template: 'header header header' auto 'nav main aside' 1fr 'footer footer footer' auto / 200px 1fr 200px;

Gap between items?

Show ▼

Both support gap: 1rem; — replaces margin hacks.

Auto-place a number of items into a responsive grid?

Show ▼

grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));

auto-fit vs auto-fill?

Show ▼

auto-fill: keeps empty tracks even if not used (collapses to min).
auto-fit: collapses empty tracks (items stretch).

Span 2 columns?

Show ▼

grid-column: span 2 or grid-column: 1 / 3.

Span all columns?

Show ▼

grid-column: 1 / -1 — line names go to last.

Order items differently than DOM?

Show ▼

order: -1 (flex/grid) — but it harms accessibility/tab order. Reserve for visual reorder where the source order is intentional.

🎓 Start studying CSS Grid Vs Flexbox When To Use Which

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

📖 Learning Resources