Tutorials Tailwind CSS Grid Placement
Ch 14 / 45
Chapter 14 Intermediate 8 min read Tailwind CSS

Grid Placement in Tailwind CSS

Chapter 13 gave you the grid container. Now take precise control of where items land. CSS Grid numbers every column and row boundary — these are called grid lines. col-start-* / col-end-* and row-start-* / row-end-* pin any item to any intersection. Add grid-flow-* to direct auto-placement and auto-cols-* / auto-rows-* to size the tracks the browser creates automatically.

Advertisement
Google Ad Placeholder · 728×90 Leaderboard
What you'll learn
Understand grid lines — how CSS numbers every column and row boundary
Place items precisely with col-start-* and col-end-*
Control vertical placement with row-start-* and row-end-*
Direct auto-placement with grid-flow-row, grid-flow-col, and grid-flow-dense
Size implicit tracks with auto-cols-* and auto-rows-*
Build a magazine layout and horizontal scroll strip using only grid utilities

Grid Lines — The Invisible Coordinate System

Every CSS Grid has an invisible coordinate system. For a 4-column grid, CSS creates 5 vertical lines numbered 1 to 5 (left to right). It also numbers them from the right as -1 to -5. Row lines work the same way vertically. col-start-* and col-end-* use these line numbers to pin items to exact positions — like giving GPS coordinates to each grid child.

4-column grid — vertical line numbers (positive + negative) col 1 col 2 col 3 col 4 1 2 3 4 5 -5 -4 -3 -2 -1 Positive lines (L→R) Negative lines (R→L) N cols = N+1 lines Examples col-start-2 col-end-4 line 2 → line 4 (2 cols) col-start-1 col-end-[-1] line 1 → last line (full) col-start-3 col-span-2 start line 3, span 2 cols col-end is exclusive item stops before that line
N+1 Lines
A 4-col grid has 5 vertical lines (1–5). A 3-row grid has 4 horizontal lines (1–4). Lines exist on both sides of every track.
Positive & Negative
Lines count left-to-right as 1, 2, 3… and right-to-left as -1, -2, -3… col-end-[-1] always means the last line regardless of column count.
Explicit Placement
col-start-2 col-end-4 pins an item from line 2 to line 4 — spanning exactly 2 columns regardless of what other items do.
Mix & Match
Combine line placement with span: col-start-3 col-span-2 means "start at line 3, be 2 columns wide" — cleaner than specifying an end line.
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

col-start-* & col-end-* — Column Placement

col-start-N sets the column line where an item begins. col-end-N sets the line where it ends (exclusive — the item stops at that line, not inside it). Together they give precise control over horizontal position — replacing col-span-* when you need exact pinning, not just a width.

grid grid-cols-4 — col-start / col-end placement examples L1 L2 L3 L4 L5 1. col-start-1 col-end-3 → cols 1–2 2. col-start-2 col-end-5 → cols 2–4 3. col-start-1 col-end-[-1] → full width (line 1 to last line) 4. col-start-3 col-end-5 → cols 3–4 5. col-start-2 col-span-2 → cols 2–3 col-end is exclusive — item stops before that line
col-start-1…13
grid-column-start: N — Pins the item's left edge to line N. In a 4-col grid valid values are 1–5. col-start-2 starts at line 2, leaving the first column empty.
col-start-auto
grid-column-start: auto — Default. The browser auto-places the item in the next available cell, flowing left-to-right, top-to-bottom.
col-end-1…13
grid-column-end: N — Pins the item's right edge to line N (exclusive). col-start-2 col-end-4 spans lines 2–4, covering exactly 2 columns.
col-end-auto
grid-column-end: auto — The browser calculates the end line from start + span. Default for any item without explicit end.
col-start-* + col-span-*
Combination pattern — col-start-3 col-span-2 is often cleaner than col-start-3 col-end-5: state where to start and how wide, not where to end.
HTML — col-start / col-end placement patterns
<!-- 4-col grid: sidebar + main explicit placement -->
<div class="grid grid-cols-4 gap-4 min-h-screen">

  <!-- Sidebar: col 1 only (line 1 to line 2) -->
  <aside class="col-start-1 col-end-2 bg-gray-900 p-4 rounded-xl">
    Sidebar
  </aside>

  <!-- Main: cols 2–4 (line 2 to line 5) -->
  <main class="col-start-2 col-end-5 bg-gray-800 p-6 rounded-xl">
    Main content (3 cols wide)
  </main>

  <!-- Footer: always full width using negative line -->
  <footer class="col-start-1 col-end-[-1] bg-gray-950 p-4 rounded-xl">
    Full-width footer (works for any column count)
  </footer>
</div>

<!-- Cleaner: combine start + span -->
<div class="grid grid-cols-12 gap-4">
  <div class="col-start-2 col-span-10 bg-blue-900 p-4 rounded-xl">
    Centred content (skips 1 col each side)
  </div>
</div>

row-start-* & row-end-* — Row Placement

Row placement mirrors column placement — just on the vertical axis. row-start-N sets the top line and row-end-N sets the bottom line (exclusive). Combine row and column placement to position any item at any cell intersection — the foundation of full editorial grid layouts.

3-col × 3-row grid — explicit row + column placement R1 R2 R3 R4 Header col-start-1 col-end-[-1] · row-start-1 row-end-2 Sidebar col 1 · rows 2–4 Main Content row-start-2 row-end-3 Widget col 4 · rows 2–4 Footer / Related row-start-3 row-end-4
row-start-1…7
grid-row-start: N — Pins the item's top edge to horizontal line N. For a 3-row grid, valid values are 1–4. row-start-2 starts below the first row track.
row-start-auto
grid-row-start: auto — Browser places the item in the next available row cell automatically. Default for all grid items.
row-end-1…7
grid-row-end: N — Pins the item's bottom edge to line N (exclusive). row-start-2 row-end-4 spans rows 2–3, two row tracks tall.
row-end-auto
grid-row-end: auto — Browser calculates end automatically. Usually 1 row tall unless row-span-* is also set.
row-start-* + row-span-*
Combination pattern — row-start-2 row-span-2 is often clearer than row-start-2 row-end-4. State start position and height in tracks.
HTML — row-start / row-end — classic app shell layout
<!-- App shell: header / sidebar+main / footer -->
<div class="grid grid-cols-[240px_1fr] grid-rows-[64px_1fr_56px] min-h-screen gap-0">

  <!-- Header: spans all columns, occupies row track 1 -->
  <header class="col-start-1 col-end-[-1] row-start-1 row-end-2
            bg-gray-900 px-6 flex items-center">
    Navbar
  </header>

  <!-- Sidebar: column 1, row track 2 -->
  <aside class="col-start-1 col-end-2 row-start-2 row-end-3
           bg-gray-800 p-4 overflow-y-auto">
    Side Navigation
  </aside>

  <!-- Main: column 2, row track 2 -->
  <main class="col-start-2 col-end-3 row-start-2 row-end-3
          bg-white p-8 overflow-auto">
    Page content
  </main>

  <!-- Footer: spans all columns, row track 3 -->
  <footer class="col-start-1 col-end-[-1] row-start-3 row-end-4
           bg-gray-950 px-6 flex items-center">
    Footer
  </footer>
</div>
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

grid-flow-* — Auto-Placement Direction

When grid items don't have explicit placement, the browser auto-places them using the grid auto-placement algorithm. grid-flow-* controls which direction the algorithm walks: row by row (default), column by column, or with dense packing to backfill gaps left by larger items.

grid-flow-row
grid-auto-flow: row — Default. Items fill left-to-right, creating new rows as needed. Like reading order — left to right, top to bottom. Every grid starts here unless overridden.
grid-flow-col
grid-auto-flow: column — Items fill top-to-bottom, creating new columns. Paired with auto-cols-* and overflow-x-auto it creates a horizontal scroll strip.
grid-flow-dense
grid-auto-flow: dense — After placing all items, the browser backfills gaps with smaller items. Can change visual order — use with caution for accessibility (tab order follows DOM, not visual position).
grid-flow-row-dense
grid-auto-flow: row dense — Row flow + dense packing. The most useful dense variant for bento grids where wide cards leave empty cells after them.
grid-flow-col-dense
grid-auto-flow: column dense — Column flow + dense packing. Used when grid-flow-col would leave column gaps that smaller items can fill.
HTML — grid-flow patterns
<!-- grid-flow-row-dense: fills gaps in bento grid -->
<div class="grid grid-cols-3 grid-flow-row-dense gap-4">
  <div class="col-span-2 bg-cyan-900 p-4 rounded-xl">Wide card (leaves 1 col gap)</div>
  <div class="col-span-2 bg-cyan-900 p-4 rounded-xl">Wide card</div>
  <div class="bg-cyan-700 p-4 rounded-xl">Small — fills first gap</div>
  <div class="bg-cyan-700 p-4 rounded-xl">Small — fills next gap</div>
</div>

<!-- grid-flow-col: horizontal strip (top-to-bottom per column) -->
<div class="grid grid-rows-1 grid-flow-col auto-cols-[280px] gap-4 overflow-x-auto">
  <div class="bg-purple-900 p-6 rounded-xl h-44">Card A</div>
  <div class="bg-purple-900 p-6 rounded-xl h-44">Card B</div>
  <div class="bg-purple-900 p-6 rounded-xl h-44">Card C</div>
</div>
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

auto-cols-* & auto-rows-* — Implicit Track Sizing

When the grid auto-placement algorithm creates new tracks beyond your defined grid-cols-* or grid-rows-*, those are called implicit tracks. By default they size to fit their content. auto-rows-* and auto-cols-* give you control — ensuring consistent card heights or a precise-width horizontal scroll strip.

Without auto-rows — uneven heights tall card short medium very tall ✗ rows size to content With auto-rows-[100px] — uniform Card 1 Card 2 Card 3 Card 4 ✓ every implicit row exactly 100px
auto-cols-auto
grid-auto-columns: auto — Default. Implicit columns grow to fit content. Used when grid-flow-col creates new columns beyond the defined grid.
auto-cols-min
grid-auto-columns: min-content — Implicit columns as narrow as the smallest non-breakable content unit. Good for compact icon columns.
auto-cols-max
grid-auto-columns: max-content — Implicit columns stretch to fit the longest content without wrapping. Useful for form label columns.
auto-cols-fr
grid-auto-columns: minmax(0, 1fr) — Implicit columns share space equally. Each new column auto-placed by grid-flow-col gets an equal share of the row width.
auto-rows-[value]
Arbitrary sizing — auto-rows-[120px] makes every implicit row exactly 120px. Most practical use: consistent card-grid row heights without hardcoding each row in grid-rows-*.
HTML — auto-cols / auto-rows patterns
<!-- 1. Uniform card heights with auto-rows -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 auto-rows-[240px] gap-6">
  <div class="bg-gray-800 rounded-2xl overflow-hidden">Card A</div>
  <div class="bg-gray-800 rounded-2xl overflow-hidden col-span-2">Wide card</div>
  <div class="bg-gray-800 rounded-2xl overflow-hidden">Card C</div>
</div>
<!-- Every implicit row is exactly 240px regardless of content -->

<!-- 2. Horizontal scroll strip with grid-flow-col + auto-cols -->
<div class="grid grid-rows-1 grid-flow-col auto-cols-[280px] gap-4 overflow-x-auto pb-2">
  <div class="bg-cyan-900 rounded-xl p-6 h-44">Card 1</div>
  <div class="bg-cyan-900 rounded-xl p-6 h-44">Card 2</div>
  <div class="bg-cyan-900 rounded-xl p-6 h-44">Card 3</div>
  <div class="bg-cyan-900 rounded-xl p-6 h-44">Card 4</div>
  <div class="bg-cyan-900 rounded-xl p-6 h-44">Card 5</div>
</div>
Pro Tip The horizontal scroll strip pattern (grid grid-rows-1 grid-flow-col auto-cols-[280px] overflow-x-auto) is more predictable than Flexbox for this use case — each card is exactly 280px regardless of content. Add snap-x snap-mandatory to the container and snap-start to each card for native CSS scroll snapping with no JavaScript.

Real-World: Magazine Layout

Combining col-start-*, col-end-*, row-start-*, row-end-*, and auto-rows-[...] gives you full editorial control — a magazine layout with a large hero, a sidebar stack, a breaking news band, and a horizontal teaser strip, all from Tailwind utilities without custom CSS.

HTML — Magazine layout using full grid placement
<!-- 12-col grid, 3 row heights: hero / band / teaser strip -->
<div class="grid grid-cols-12 grid-rows-[340px_auto_200px]
           gap-4 p-4 bg-gray-950 min-h-screen">

  <!-- Hero story: 8 cols wide, row 1 -->
  <article class="col-start-1 col-span-8 row-start-1 row-end-2
            relative rounded-2xl overflow-hidden bg-gray-800">
    <img src="hero.jpg" alt="Hero" class="w-full h-full object-cover">
    <div class="absolute bottom-0 left-0 right-0 p-6
            bg-gradient-to-t from-black/80 to-transparent">
      <span class="text-xs text-cyan-400 font-semibold uppercase tracking-wider">Tech</span>
      <h2 class="text-3xl font-bold text-white mt-1">Tailwind CSS v4 is Here</h2>
    </div>
  </article>

  <!-- Sidebar stack: last 4 cols, row 1 -->
  <div class="col-start-9 col-end-[-1] row-start-1 row-end-2 flex flex-col gap-4">
    <article class="flex-1 bg-gray-800 rounded-2xl p-4">Side Story 1</article>
    <article class="flex-1 bg-gray-800 rounded-2xl p-4">Side Story 2</article>
  </div>

  <!-- Breaking news band: full width, row 2 -->
  <div class="col-start-1 col-end-[-1] row-start-2 row-end-3
           bg-cyan-600 text-white px-6 py-3 rounded-xl flex items-center gap-4">
    <span class="font-bold text-sm uppercase tracking-widest shrink-0">Breaking</span>
    <p class="text-sm">CSS Grid Placement supported in all major browsers</p>
  </div>

  <!-- Teaser strip: horizontal scroll, row 3 -->
  <div class="col-start-1 col-end-[-1] row-start-3 row-end-4
           grid grid-rows-1 grid-flow-col auto-cols-[240px] gap-4 overflow-x-auto pb-2">
    <article class="bg-gray-800 rounded-xl p-4">Teaser 1</article>
    <article class="bg-gray-800 rounded-xl p-4">Teaser 2</article>
    <article class="bg-gray-800 rounded-xl p-4">Teaser 3</article>
    <article class="bg-gray-800 rounded-xl p-4">Teaser 4</article>
    <article class="bg-gray-800 rounded-xl p-4">Teaser 5</article>
  </div>
</div>
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

Quick Reference — All Grid Placement Utilities

Class CSS Property Notes
col-start-1…13 grid-column-start: N Pin item left edge to line N
col-start-auto grid-column-start: auto Browser auto-places item ★
col-end-1…13 grid-column-end: N Pin item right edge (exclusive)
col-end-auto grid-column-end: auto Browser calculates end automatically
col-start-1 col-end-[-1] grid-column: 1 / -1 Full-width row — any col count ★
col-start-N col-span-M grid-column: N / span M Start at line N, M cols wide ★
row-start-1…7 grid-row-start: N Pin item top edge to row line N
row-start-auto grid-row-start: auto Browser auto-places in next row
row-end-1…7 grid-row-end: N Pin item bottom edge (exclusive)
row-end-auto grid-row-end: auto Browser calculates end automatically
row-start-N row-span-M grid-row: N / span M Start at row N, M rows tall ★
grid-flow-row grid-auto-flow: row Default — L→R, new rows ★
grid-flow-col grid-auto-flow: column T→B, new columns
grid-flow-dense grid-auto-flow: dense Fill gaps (changes DOM order)
grid-flow-row-dense grid-auto-flow: row dense Row + dense packing ★
grid-flow-col-dense grid-auto-flow: column dense Column + dense packing
auto-cols-auto grid-auto-columns: auto Implicit cols fit content
auto-cols-min grid-auto-columns: min-content Narrowest content width
auto-cols-max grid-auto-columns: max-content Widest content width
auto-cols-fr grid-auto-columns: minmax(0,1fr) Share available space equally
auto-rows-[120px] grid-auto-rows: 120px Fixed implicit row height ★
auto-cols-[280px] grid-auto-columns: 280px Fixed col width — scroll strip ★

★ = most commonly used in real projects

Featured Course
Master Tailwind CSS — Grid, Layout & Production UI
Go from grid basics to building pixel-perfect magazine layouts and dashboards. Our structured course covers all Tailwind v4 utilities, custom themes, and 5 real-world projects with live mentoring.
45 Chapters 10+ Hours 5 Real Projects Certificate Live Mentoring
🗺️
⭐ 4.9 · 1,200+ students
Tailwind CSS Grid Placement Cheat Sheet
Download our free one-page cheat sheet covering all grid placement utilities — col-start, col-end, row-start, row-end, grid-flow, auto-cols, auto-rows, and the magazine layout pattern with visual examples.
col-start / col-end row-start / row-end grid-flow-* auto-cols-* auto-rows-* Grid Lines
Download Free Cheat Sheet
Chapter Summary
  • Grid lines — A 4-column grid has 5 vertical lines numbered 1–5 (L→R) and also -1 to -5 (R→L). col-end-[-1] always means the last line regardless of how many columns the grid has.
  • col-start / col-end — Pin any item to any column line. col-start-2 col-end-4 spans lines 2–4, covering exactly 2 columns. End is exclusive.
  • col-start + col-span — Combine for clarity: col-start-3 col-span-2 reads "start at line 3, span 2 columns wide" — often cleaner than specifying an end line.
  • row-start / row-end — Vertical counterpart to column placement. Use both together for full 2D control: col-start-1 col-end-2 row-start-2 row-end-4 = exact cell intersection.
  • grid-flow-row-dense — After placing all items normally, backfills gaps with smaller items. Essential for bento grids where wide cards leave empty cells.
  • grid-flow-col — Changes auto-placement to top-to-bottom. Pair with auto-cols-[280px] and overflow-x-auto for a horizontal scroll strip.
  • auto-rows-[N] — Gives all implicit rows a fixed height. Most practical: auto-rows-[240px] makes every card-grid row exactly 240px without hardcoding each row in grid-rows-*.
  • Next chapter covers Padding — the p-*, px-*, py-*, pt-* utilities and the 4px spacing scale used throughout every Tailwind layout.

Quick Check — Questions & Answers

Test your understanding of this chapter. Click a question to reveal the answer.

A 4-column grid has 5 vertical lines, numbered 1 through 5 from left to right. CSS also numbers them from the right: line 5 = line -1, line 4 = line -2, etc. So -1 always refers to the last vertical line (the right edge of the grid).

This is why col-start-1 col-end-[-1] creates a full-width item regardless of how many columns the grid has — it always spans from the first to the very last line.

col-end-3 says "stop at line 3" — an absolute position. If the item starts at line 1 it spans 2 columns. If it starts at line 2, it spans only 1 column.

col-span-3 says "be 3 columns wide" — a relative width. col-start-2 col-span-3 occupies lines 2–5 (columns 2, 3, 4) regardless of context.

Use col-end-* when the end position matters absolutely. Use col-span-* when the width matters. Combining start + span is usually the clearest pattern.

Use grid-flow-dense (or grid-flow-row-dense) when your grid has items of different sizes — like a bento layout where some cards span 2 columns — and you don't want the grid to leave gaps after wider items.

Accessibility trade-off: dense packing can move items out of DOM order. A smaller item from position 5 in the HTML might visually appear before item 3 to fill a gap. This breaks keyboard navigation and screen reader order since tab order follows DOM order, not visual order.

Only use dense packing for purely decorative grids where order doesn't matter. Never use it for navigation links or interactive form elements.

An implicit track is a row or column the browser creates automatically when grid items overflow the explicitly defined tracks.

Example: you define grid-cols-3 and place 9 items. The browser creates 3 rows automatically — those are implicit. By default they size to fit content, causing uneven heights in a card grid.

Control implicit row size with auto-rows-*: auto-rows-[240px] makes every auto-created row exactly 240px tall. Control implicit column size (created by grid-flow-col) with auto-cols-*: auto-cols-[280px] makes every auto-column exactly 280px wide.

Combine grid-rows-1 (one row), grid-flow-col (items flow left-to-right as new columns), auto-cols-[280px] (each implicit column is exactly 280px wide), and overflow-x-auto (horizontal scroll when content exceeds container):

<div class="grid grid-rows-1 grid-flow-col auto-cols-[280px] gap-4 overflow-x-auto">

Each child becomes a 280px-wide card in a single row. The grid grows rightward automatically. This is more predictable than Flexbox because each card has an exact width. Add snap-x snap-mandatory to the container and snap-start to each card for native CSS scroll snapping.

MCQ Quiz — Test Yourself

Select the best answer for each question. Correct answers are revealed after you click.

Question 1 of 4
In a 4-column grid, what does col-start-2 col-end-4 do?
Question 2 of 4
Which grid-flow-* value places items top-to-bottom, creating new columns as needed?
Question 3 of 4
What is the cleanest way to place an item starting at column line 3 and spanning 2 columns?
Question 4 of 4
Which combination builds a horizontal scroll strip where each card is exactly 280px wide?

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel