CSS ยท Chapter 25 of 44

CSS Grid Item Placement

Individual grid items can be placed precisely using grid-column and grid-row, specifying start and end lines, or by using named grid-template-areas.

This lets you create complex layouts like magazine-style grids where items span multiple rows or columns.

Syntax
grid-column: start / end;
grid-row: start / end;

Line-based placement

grid-column: 1 / 3; places an item spanning from line 1 to line 3 (covering two columns). grid-row works the same way for rows.

Named areas

grid-template-areas defines a visual map of named regions, and grid-area assigns an item to one of those named regions.

Example 1 (css)
.hero {
  grid-column: 1 / 3;
  grid-row: 1;
}
Output
The hero item spans across two columns in the first row

grid-column: 1 / 3 tells the item to stretch from the first grid line to the third.

Key points

  • grid-column and grid-row use start/end line numbers.
  • Items can span multiple columns or rows.
  • grid-template-areas creates named layout regions.
  • grid-area assigns an item to a named area.
๐Ÿ’ก Note: You can use span keyword, like grid-column: span 2; to cover two columns from the current position.

๐Ÿ“ Quick Quiz

1. What does grid-column: 1 / 3; do?

2. Which property assigns an item to a named grid area?

3. Which keyword lets an item cover 2 columns from its position?