Spanning Rows & Columns

Grid items can span across multiple tracks in either direction. This is how you create complex, magazine-style layouts where some items are larger than others. sdfsdfs

grid-column: span Ngrid-row: span Ngrid-columngrid-row

1. Column Spanning

Make an item span multiple columns. The item occupies multiple column tracks while other items flow around it.

CSS

.header { grid-column: span 3; } /* full width */
.wide   { grid-column: span 2; } /* 2 of 3 cols */
.normal { /* no span — just 1 column */ }
Spans all 3 columns
Spans 2 cols
1
1
Spans 2 cols

2. Row Spanning

Make an item taller by spanning multiple rows. This is the key technique for creating sidebar layouts and featured image cards.

CSS

.container {
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 70px; /* consistent row heights */
}
.tall-3  { grid-row: span 3; }
.tall-2  { grid-row: span 2; }
Spans 3 rows tall
item
item
Spans 2 rows
item
item
item

3. Spanning Both Axes

An item can span multiple columns AND multiple rows simultaneously, creating a larger grid cell. This is perfect for featured content areas.

CSS

.featured {
  grid-column: span 2; /* 2 columns wide */
  grid-row:    span 2; /* 2 rows tall    */
}
/* creates a 2×2 cell in the grid */
2×2 Featured
col span 2, row span 2
item
item
item
item
col span 2
item
item

4. Magazine-Style Layout

Combining column and row spanning creates rich editorial layouts. Use explicit placement + spanning together.

CSS

.container {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 80px 80px 80px;
}
.hero  { grid-column: 1 / 3;   grid-row: 1 / 3; }
.wide  { grid-column: 3 / 5;   grid-row: 2;     }
🖼️ Hero Image
cols 1-3, rows 1-3
Story 1
Story 2
Wide Story
Short
Short
Short
Short
This is the foundation of every newspaper/magazine layout built with CSS Grid. Combine explicit placement with span for maximum flexibility.

5. Pinterest-Style Variable Heights

CSS Grid doesn't natively support masonry layout (random heights filling gaps), but you can approximate it with row spans. True masonry requires JavaScript or the CSS masonry spec (in development).

CSS

.container {
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 40px; /* base unit */
  grid-auto-flow: dense; /* fill gaps (see Dense topic) */
}
.tall   { grid-row: span 3; }
.medium { grid-row: span 2; }
.short  { grid-row: span 1; }
tall
medium
short
short
tall
medium
medium
short
For true auto-filling masonry (like Pinterest), combine row spanning with grid-auto-flow: dense. The Dense Packing topic shows this in detail.