Tailwind CSS interview question · Most asked

What's the difference between flex and grid in Tailwind, and when do you use each?

Create a free account to save this page, take notes and track your progress. Sign in

Summary

flex lays items out in one dimension (a row or column) with alignment via items-* and justify-; ideal for navbars, toolbars and centring. grid lays out in two dimensions with grid-cols-, col-span-* and gap; ideal for card grids and page layouts. They combine: a grid of cards whose insides use flex.

Longer Answer

grid-cols-[repeat(auto-fill,minmax(12rem,1fr))] makes responsive card grids without breakpoints.

Key Points

  • flex: one dimension.
  • grid: two dimensions.
  • gap in both.
  • Combine them.

Deep dive: Tailwind CSS Tutorial: CSS Grid

Explanation

What interviewers look for

Picks the right tool with examples.

More most-asked Tailwind CSS questions

← All Tailwind CSS questions

Was this page helpful?