Tailwind CSS·Tailwind from utilities to design system

Grid with utilities

Build two-dimensional layouts with grid-cols, spans and auto-fit patterns.

Intermediate 13 min read Lesson 5 of 300 Challenge included
What you will be able to do
  • Use grid and gap for the base.
  • Use col-span-* to place items across columns.
  • Use auto-fit with minmax for card grids.
  • Keep the DOM order meaningful when reordering visually.

In plain English

Grid is for layouts that need rows and columns at the same time. Use grid-cols-12 for bespoke layouts and grid-cols-[repeat(auto-fit,minmax(...))] for responsive card walls without media queries.

grid.htmlHTML
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
  <article class="rounded-xl border border-slate-200 p-4">HTML</article>
  <article class="rounded-xl border border-slate-200 p-4">CSS</article>
  <article class="rounded-xl border border-slate-200 p-4">JavaScript</article>
</div>
Your turn

Make a responsive card wall

Medium

Create a grid with auto-fit tracks at least 200px wide and a gap of 4.

HTML · starter
<div class="grid gap-4">
Check your understanding before moving on.
Knowledge checkQuestion 1

Which class makes one column on mobile and three from md up?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Responsive design
Lesson 5 of 300 · 0% of course