Tutorials CSS Grid Items & Placement
Ch 31 / 60
Chapter 31 Intermediate 9 min read CSS

CSS Grid Items & Placement

Chapter 30 covered the container properties that define the grid structure. This chapter covers the other half — properties applied to individual grid items. These let you place items precisely anywhere in the grid, span them across multiple rows or columns, align them within their cell, and even overlap them.

What you'll learn
grid-column — place and span across columns
grid-row — place and span across rows
The span keyword — span N tracks
grid-area — four-value shorthand or named area
justify-self & align-self — per-cell alignment
Overlapping items with z-index

All Grid Item Properties — Quick Reference

These properties are applied to individual grid items (direct children of a grid container):

grid-column-start
default: auto
Column line where the item starts. Integer, named line, or span N.
grid-column-end
default: auto
Column line where the item ends. Integer, named line, or span N.
grid-column
shorthand
Shorthand: grid-column: start / end. Most common way to place items.
grid-row-start
default: auto
Row line where the item starts.
grid-row-end
default: auto
Row line where the item ends.
grid-row
shorthand
Shorthand: grid-row: start / end.
grid-area
auto / auto / auto / auto
4-value shorthand (row-start/col-start/row-end/col-end) or a named area from grid-template-areas.
justify-self
default: stretch
Aligns item within its cell along the inline (horizontal) axis. Overrides justify-items.
align-self
default: stretch
Aligns item within its cell along the block (vertical) axis. Overrides align-items.
place-self
shorthand
Shorthand for align-self + justify-self in Grid. Both axes work here (unlike Flexbox).

grid-column — Column Placement

grid-column is shorthand for grid-column-start / grid-column-end. You specify which column lines the item starts and ends at. All demos use a 4-column grid:

grid-column: 1 / 3 — spans cols 1 and 2
3
4
5
6
7
8
grid-column: 2 / 5 — spans cols 2, 3, 4
1
5
6
7
8
grid-column: 1 / -1 — full width (all columns)
2
3
4
5
grid-column: 3 / 3 — single cell (no span)
1
2
4
5
6
7
8
Negative line numbers
Grid lines can also be referenced from the end using negative numbers. -1 is always the last line regardless of how many columns there are. grid-column: 1 / -1 always spans the full width — very useful for headers and footers that must stretch across all columns.
CSS — grid-column
/* grid-column: start / end */
.item { grid-column: 1 / 3; }     /* lines 1→3, spans 2 cols */
.item { grid-column: 2 / 5; }     /* lines 2→5, spans 3 cols */
.item { grid-column: 1 / -1; }    /* full width (start to last line) */
.item { grid-column: 3; }         /* col 3 only (start only → auto end) */

/* Longhand equivalents */
.item {
  grid-column-start: 1;
  grid-column-end:   3;
}

/* Named lines (from grid-template-columns: [col-start] 1fr [col-end]) */
.item { grid-column: col-start / col-end; }

/* Real-world: header spans all columns */
.header { grid-column: 1 / -1; }
.footer { grid-column: 1 / -1; }

grid-row — Row Placement

grid-row is the row equivalent of grid-column. It places the item by specifying start and end row lines. All demos use a 3-row, 3-column grid:

grid-row: 1 / 3 — spans rows 1 and 2
B
C
D
E
F
G
H
grid-row: 1 / 4 — spans all 3 rows
B
C
D
E
F
G
CSS — grid-row
/* grid-row: start / end */
.item { grid-row: 1 / 3; }   /* lines 1→3, spans 2 rows */
.item { grid-row: 2 / 4; }   /* lines 2→4, spans 2 rows */
.item { grid-row: 1 / -1; }  /* all rows */
.item { grid-row: 2; }       /* row 2 only */

/* Combined with grid-column */
.sidebar {
  grid-column: 1 / 2;
  grid-row:    2 / 4;  /* rows 2–3 */
}
.hero {
  grid-column: 1 / -1; /* full width */
  grid-row:    1 / 2;
}

The span Keyword

Instead of specifying exact end line numbers, the span keyword lets you say "span N tracks from wherever this item lands". It works with auto-placement so you don't need to know exact positions:

span 2 — spans 2 columns from auto-placed position
1
4
6
7
8
span 3 — spans 3 columns
4
5
span 2 rows — grid-row: span 2
B
C
D
E
F
G
H
CSS — span keyword
/* span N — span N tracks from current position */
.item { grid-column: span 2; }    /* span 2 columns */
.item { grid-column: span 3; }    /* span 3 columns */
.item { grid-row:    span 2; }    /* span 2 rows */

/* span from a fixed start position */
.item { grid-column: 2 / span 3; }  /* start at col 2, span 3 */
.item { grid-row:    1 / span 2; }  /* start at row 1, span 2 */

/* Compare: line numbers vs span */
.a { grid-column: 1 / 3; }      /* absolute lines — same result as: */
.b { grid-column: 1 / span 2; } /* span from line 1 */

/* Real-world: featured card in a grid */
.card-featured {
  grid-column: span 2;
  grid-row:    span 2;
}

grid-area — Shorthand and Named Areas

grid-area has two distinct uses. The first is as a 4-value line-number shorthand. The second is assigning an item to a named area from grid-template-areas on the container:

grid-area: row-start / col-start / row-end / col-end
A
B
C
F
G

grid-area: 2/1/4/3

grid-area: named — matches grid-template-areas
sidebar
main
footer
CSS — grid-area both forms
/* ── Form 1: 4-value line shorthand ──
   grid-area: row-start / col-start / row-end / col-end */
.item { grid-area: 1 / 1 / 3 / 3; }
/*              ↑row-s ↑col-s ↑row-e ↑col-e
   = grid-row:1/3; grid-column:1/3; */

.item { grid-area: 2 / 1 / 4 / -1; } /* rows 2–3, full width */

/* ── Form 2: Named area from grid-template-areas ── */
.container {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
}
.header  { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main    { grid-area: main; }
.footer  { grid-area: footer; }

/* ⚠ Don't mix both forms for the same item */

justify-self & align-self — Per-Cell Alignment

In Grid, justify-self and align-self both work fully (unlike Flexbox where justify-self has no effect). They align an item within its grid cell along the inline and block axes respectively:

justify-self — horizontal (inline axis)

align-self — vertical (block axis)

place-self: center — centres item within its cell (both axes)
stretch
stretch
stretch
stretch
stretch
CSS — justify-self, align-self, place-self
.container {
  display:       grid;
  justify-items: stretch;  /* default for all items */
  align-items:   stretch;  /* default for all items */
}

/* justify-self: horizontal position within the cell */
.item { justify-self: stretch; }   /* default — fills cell width */
.item { justify-self: start; }     /* left edge of cell */
.item { justify-self: end; }       /* right edge of cell */
.item { justify-self: center; }    /* centred horizontally */

/* align-self: vertical position within the cell */
.item { align-self: stretch; }     /* default — fills cell height */
.item { align-self: start; }       /* top of cell */
.item { align-self: end; }         /* bottom of cell */
.item { align-self: center; }      /* vertically centred */

/* place-self: shorthand for align-self + justify-self */
.item { place-self: center; }      /* centred in cell both ways */
.item { place-self: start end; }   /* top-right of cell */

/* ✓ In Grid: justify-self works (unlike Flexbox!) */

Overlapping Items & z-index

CSS Grid items can occupy the same cells. This is intentional — you explicitly assign two items to overlapping positions. Control which one appears on top with z-index:

A
B
C
D
E
F
Overlay (z:1)

Purple item assigned to grid-column:1/3 + grid-row:1/3. z-index:1 puts it on top.

CSS — overlapping grid items
.grid {
  display:              grid;
  grid-template-columns:repeat(3, 1fr);
  grid-template-rows:   repeat(2, 100px);
}

/* Two items placed in the same area */
.background-image {
  grid-column: 1 / 3;
  grid-row:    1 / 3;
  z-index:     0;   /* behind */
}
.overlay-text {
  grid-column: 1 / 3;
  grid-row:    1 / 3;  /* same cells! */
  z-index:     1;   /* on top */
  place-self:  center;
}

/* Real use: photo card with text overlay */
.photo   { grid-area: 1 / 1 / 3 / 4; z-index: 0; }
.caption { grid-area: 2 / 1 / 3 / 4; z-index: 1; align-self: end; }

Real-World Placement Patterns

Putting it all together — the most common page and component layout patterns using grid placement:

Pattern 1 — Classic header/sidebar/main/footer page layout
Sidebar
col:1
Main Content
col:2
Footer — grid-column:1/-1
Pattern 2 — Magazine with featured article (spans 2 rows)
Card 3
Card 4
Pattern 3 — Dashboard with stats + wide chart
Stat 1
Stat 2
Stat 3
Stat 4
CSS — common placement patterns
/* ── Pattern 1: Classic page layout ── */
.page {
  display:              grid;
  grid-template-columns:260px 1fr;
  grid-template-rows:   64px 1fr 48px;
  min-height:           100vh;
}
.header  { grid-column: 1 / -1; }     /* full width */
.sidebar { grid-row: 2; }              /* auto-placed in col 1 */
.main    { grid-row: 2; }              /* auto-placed in col 2 */
.footer  { grid-column: 1 / -1; }     /* full width */

/* ── Pattern 2: Featured article ── */
.magazine { grid-template-columns: repeat(3, 1fr); }
.featured {
  grid-column: 1 / 3;  /* spans 2 cols */
  grid-row:    1 / 3;  /* spans 2 rows */
}

/* ── Pattern 3: Dashboard ── */
.dashboard { grid-template-columns: repeat(4, 1fr); }
.full-chart { grid-column: 1 / -1; }      /* spans all 4 cols */

All Item Properties — Complete Reference

Property Default Values Controls
grid-column-start auto integer, named line, span N Start column line
grid-column-end auto integer, named line, span N End column line
grid-column auto / auto start / end Shorthand: column placement
grid-row-start auto integer, named line, span N Start row line
grid-row-end auto integer, named line, span N End row line
grid-row auto / auto start / end Shorthand: row placement
grid-area auto/auto/auto/auto row-s/col-s/row-e/col-e or area-name Shorthand: all placement or named area
justify-self stretch stretch, start, end, center Inline axis within cell
align-self stretch stretch, start, end, center Block axis within cell
place-self stretch stretch align-self + justify-self Both axes within cell
Free Resource
CSS3 Cheat Sheet — All Properties & Selectors
Complete reference covering all CSS Grid item and container properties with visual examples.
Download PDF

Try It Yourself

All placement properties in one editor. Try changing line numbers, adding span, and experimenting with justify-self and align-self:

Live Editor
✎ Editor
👁 Preview
Featured Course — Enroll Now
Modern Web Development With AI
Master HTML, CSS, JavaScript, React and Node.js with real projects and placement support.
120+
Chapters
40 hrs
Content
10 Real
Projects
4.9 ⭐
Rating
HTML5CSS3JavaScriptReact.jsNode.jsTailwind CSSAI Tools

Quick Check — Chapter 31

Questions & Answers
Both achieve the same result when the item starts at column line 1 — they both make the item span 2 columns. But they differ in how they express the placement:

grid-column: 1 / 3 — uses absolute line numbers. The item starts at column line 1 and ends at column line 3, spanning 2 columns. This is explicit about both start and end position.

grid-column: span 2 — says "span 2 columns from wherever auto-placement puts me." The start position is determined by the auto-placement algorithm. This is relative — the item will span 2 columns from its natural position.

When to use each:
— Use line numbers (1 / 3) when the exact position matters (e.g., header must always start at column 1)
— Use span when only the size matters and position can be auto (e.g., featured cards in a flowing grid)

They can also be combined: grid-column: 2 / span 3 means "start at line 2 and span 3 columns" = lines 2 to 5.
grid-column: 1 / -1 makes an item span from the first column line to the last column line — effectively making it full width across all columns.

The -1 is a negative line reference. In CSS Grid, lines can be counted from the end: -1 is always the last line, -2 is second from last, and so on.

This is especially useful for header and footer elements in a multi-column layout. Instead of knowing the exact number of columns and writing 1 / 5 for a 4-column grid, you write 1 / -1 and it works for any number of columns. If you later change from 3 to 4 columns, the header/footer still spans the full width without changing the item CSS.
grid-area has two completely different but valid syntaxes:

Form 1 — 4-value line shorthand:
grid-area: row-start / col-start / row-end / col-end
For example: grid-area: 1 / 1 / 3 / 3 is exactly equivalent to writing both grid-row: 1/3 and grid-column: 1/3. Note the order: row-start first, then column-start.

Form 2 — Named area reference:
grid-area: header — assigns the item to a named area defined by grid-template-areas on the container. This is the most readable form for page layouts.

The two forms are mutually exclusive for a single item. Use form 1 for precise numeric placement; use form 2 when working with grid-template-areas for named, semantic layouts. Don't mix them on the same item.
The key difference is that justify-self works in Grid but has no effect in Flexbox:

In CSS Grid: Each item has its own cell (or area). justify-self aligns the item within that cell along the inline (horizontal) axis. Values: stretch (default), start, end, center. This works because each grid item has a defined cell boundary to align within.

In Flexbox: justify-self is defined but has no effect. Flexbox distributes items along the main axis collectively via justify-content — there is no per-item main-axis positioning. The workaround in Flexbox is margin: auto.

This is one reason Grid is more powerful for precise layouts — both axes have per-item control via justify-self and align-self, while Flexbox only provides per-item cross-axis control (align-self).
Grid items overlap when two or more items are explicitly placed (via grid-column / grid-row) into the same cells or overlapping cell ranges. This is intentional and powerful.

How to make items overlap:
Assign two items to the same or overlapping cell ranges:
.background { grid-column: 1/4; grid-row: 1/3; }
.overlay { grid-column: 1/4; grid-row: 1/3; }

Controlling stacking order: Use z-index. Higher values appear on top. Items without explicit z-index stack in DOM order (later items on top).

Common use cases:
— Full-bleed background image with text overlay
— Photo caption at the bottom of an image cell
— Decorative accent element behind content
— Badge or label overlaid on a card

Unlike absolute positioning, overlapping grid items still participate in the grid layout — they don't affect the placement of other items.
Multiple Choice Questions
Question 1 of 5
In a 4-column grid, what does grid-column: 1 / -1 do?
Question 2 of 5
What is the shorthand order for the 4-value form of grid-area?
Question 3 of 5
Which property aligns a grid item horizontally within its cell?
Question 4 of 5
An item has grid-column: 2 / span 3. Which column lines does it occupy?
Question 5 of 5
Two grid items are placed in the same cells. How do you control which one appears on top?
Chapter Summary
  • grid-column: start / end — places item between column lines. 1/-1 = full width. Negative numbers count from the end.
  • grid-row: start / end — places item between row lines. Same syntax and negative-number support as grid-column.
  • span N — span N tracks from current position. Can be combined with a start: 2 / span 3 = start at line 2, span 3 columns.
  • grid-area — two forms: (1) 4-value: row-start / col-start / row-end / col-end. (2) Named: grid-area: header — must match a name in grid-template-areas.
  • justify-self — horizontal alignment within the cell (stretch/start/end/center). Works in Grid (unlike Flexbox).
  • align-self — vertical alignment within the cell. Same values.
  • place-self — shorthand for align-self + justify-self. place-self: center = centred in cell on both axes.
  • Overlapping — assign two items to the same cell ranges. Use z-index to control stacking order.
  • Key patterns: header { grid-column: 1/-1 } for full-width header/footer. featured { grid-column: span 2; grid-row: span 2; } for featured cards.
~9 min read
Intermediate level
Chapter 31 of 60

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