grid-row

A shorthand property for grid-row-start and grid-row-end. It defines an item's vertical position and height within a grid in one line.

Quick example

.hero-image {
  grid-row: 1 / span 2;
} /* starts at row 1 and spans 2 rows down */

Syntax

grid-row: <grid-line> [/ <grid-line>]?
<integer>
Row line number. grid-row: 2 places the item starting at row line 2.
<line-number> / <line-number>
Start line and end line separated by slash. grid-row: 1 / 3 spans from line 1 to line 3.
span <number>
Span across a number of tracks. grid-row: span 2 makes the item take two row tracks.
<line-number> / span <number>
Start at a specific line and span a given number of tracks. grid-row: 2 / span 3 starts at line 2 and covers 3 rows.
<name>
Named grid line, defined in grid-template-rows. grid-row: header / footer places the item between those named lines.
auto
Default. Grid auto-placement decides where the item goes.

Quick facts

Initial value
See individual properties
Inherited
No
Applies to
Grid items and boxes within grid containers
Animation type
discrete

Examples

Span multiple rows

.sidebar {
  grid-row: 1 / span 3;
}

Sidebar starts at row line 1 and spans three rows down. Useful for tall content next to shorter stacked items.

Stretch to the last row

.footer {
  grid-row: -2 / -1;
}

Negative values count from the end. -1 is the last line, -2 is the second-to-last. This places the footer on the last row regardless of how many rows exist.

Explicit start and end

.hero {
  grid-row: 1 / 3;
}

Places the item starting at row line 1 and ending at row line 3. Covers two rows (line 1 to line 3 spans two cells).

grid-row Browser Support

Widely available Since 2017 95% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2017.

Safe to use without fallbacks.

57+
52+
10.1+
16+

Common pitfalls

Row lines count edges, not cells

In a 3-row grid, there are 4 row lines (line 1 above the first row, line 4 below the last). grid-row: 1 / 3 does not span three rows, it spans two (from line 1 to line 3). Off-by-one confusion is the most common grid mistake.

Span values can overflow the grid

grid-row: span 10 in a 3-row explicit grid will create 7 implicit rows to fit. The grid grows to accommodate your span, which may break your layout. Cap spans to known row counts or use explicit line numbers.

Only the start line gets the slash's left side

grid-row: 2 with no slash sets only grid-row-start. The end defaults to auto, giving a single-cell item. To span, always use the slash syntax: grid-row: 2 / span 2.

See also

ESC