Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Grid

The grid-row property

Reference for the CSS grid-row shorthand: set the start and end row lines of a grid item with numbers, names or span, with live examples and usage notes.

The grid-row property is the shorthand for grid-row-start and grid-row-end. It places a grid item vertically by naming the horizontal grid lines where the item begins and ends. The two values are separated by a slash: grid-row: 2 / 4 covers rows 2 and 3.

If you give only one value, it sets the start line; the end is auto (one row), unless the single value is a custom name, in which case the end copies it.

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

Try it

A tall item across three rows

Syntax

CSS
grid-row: <grid-line>;
grid-row: <grid-line> / <grid-line>;

/* <grid-line> */
auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
  • Initial value: auto / auto
  • Applies to: grid items and absolutely positioned boxes whose containing block is a grid container
  • Inherited: no
  • Animatable: no
  • Computed value: as specified (each longhand)

Values

Value Description
<integer> A line number. 1 is the top line of the explicit grid, -1 the bottom line.
<custom-ident> A named line, or an area name that resolves to name-start / name-end.
span <integer> Cover that many rows from the other line. 2 / span 2 covers rows 2 and 3.
auto Automatic placement or a one-row span.
a / b Start line a, end line b. The end line is not part of the item.

Usage notes

  • 1 / -1 fills every explicit row, but only the rows defined by grid-template-rows. Implicit rows are not included.
  • Rows grow only with content or grid-auto-rows. If the container has no fixed height and rows are auto, a tall item makes the rows it spans larger together.
  • A single span value after the slash is common: grid-row: 2 / span 2.
  • Name collisions. grid-row: header expects lines named header-start and header-end (created by grid-template-areas); a missing name resolves to an implicit line at the end of the grid.
  • Overlap is allowed, and later items paint above earlier ones.
  • Don't reorder meaningful content visually this way; keyboard order follows the HTML source.

Browser support

Supported in all current browsers.