Example 1 — Span Two Rows with 1 / 3
Create a simple grid and position an item to span two rows.
.item1 {
grid-row: 1 / 3;
} How It Works
Starting at row line 1 and ending at row line 3 makes Item 1 twice as tall as single-row items.

The grid-row property lets you control how many rows a grid item spans and where it starts and ends vertically.
Vertical size.
Line numbers.
Row count.
Start & end.
Default flow.
Child element.
The grid-row property in CSS is a shorthand property for defining both the start and end lines of a grid item within a grid container. It is used in CSS Grid Layout to control the placement of items within the rows of a grid, allowing for precise control over their positioning and spanning across multiple rows.
Apply grid-row on a child of a grid container with display: grid. Use line numbers like 1 / 3 when you need an item to stretch across two rows. Use span 2 when you only care how many rows an item should cover.
Row lines are numbered starting at 1. So grid-row: 1 / 3 spans from row line 1 to row line 3, covering two row tracks.
The syntax for the grid-row property combines the start and end lines of a grid item:
element {
grid-row: start / end;
} start — Specifies the starting grid line for the item.end — Specifies the ending grid line for the item.element {
grid-row-start: start;
grid-row-end: end;
} The default value of the grid-row property is auto / auto, meaning the item will be placed in the next available grid cell and will span only one row.
grid-row-start and grid-row-end.span n, named lines, and auto.| Question | Answer |
|---|---|
| Initial value | auto / auto |
| Applies to | Grid items |
| Inherited | No |
| Shorthand for | grid-row-start / grid-row-end |
| Full-height trick | grid-row: 1 / -1; |
| Value | Description |
|---|---|
auto | Default value. The item will be placed in the next available slot |
span n | The item will span n rows |
line-number | The item will start or end at the specified grid line |
span n / auto | The item will span n rows from the start line |
auto / span n | The item will span n rows from the end line |
Item 1 spans rows 1–2 with grid-row: 1 / 3 (highlighted):
Span two rows with line numbers, use span shorthand, build a full-height sidebar, and combine row and column placement.
Start with the reference example — an item spanning two rows with line numbers.
Create a simple grid and position an item to span two rows.
.item1 {
grid-row: 1 / 3;
} Starting at row line 1 and ending at row line 3 makes Item 1 twice as tall as single-row items.
Make a featured card span two rows without specifying exact line numbers.
.hero {
grid-row: span 2;
} span 2 tells the hero card to cover two row tracks from its auto-placed starting position.
Common real-world uses for row placement in page layouts.
Stretch a sidebar from the first row to the last using negative line numbers.
.sidebar {
grid-column: 1;
grid-row: 1 / -1;
} grid-row: 1 / -1 fills every row track. Combined with a fixed column, the sidebar stays full height.
Place a header in row 1 and let content fill remaining rows.
.header { grid-row: 1; grid-column: 1 / -1; }
.content { grid-row: 2 / -1; grid-column: 1 / -1; } The header occupies row 1 across all columns. Content spans from row 2 to the last row line.
<header> and <main> alongside grid placement.grid-row Worksgrid-template-rows creates numbered row tracks.
You define start and end row lines or a span on a grid item.
The item stretches vertically across the specified row tracks.
Items cover exactly the rows you need for sidebars, heroes, and headers.
The grid-row property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.
Row placement works in all major modern grid implementations.
Bottom line: Safe for modern projects. Test spanning layouts across browsers for consistent rendering.
The grid-row property is a versatile tool in CSS Grid Layout that allows developers to control the placement and spanning of grid items across rows. By using this property, you can create complex and responsive grid layouts that adapt to various screen sizes and content needs.
Experiment with different configurations to see how grid-row can enhance your web designs. Start with line numbers like 1 / 3, then try span and 1 / -1 for common layout patterns.
span n for flexible row counts1 / -1 for full-height sidebarsgrid-column for 2D layoutsgrid-rowUse these points when placing items vertically.
Vertical size.
PurposeOne row.
DefaultStart & end.
SyntaxTwo rows.
PatternNot container.
ScopeOpen the HTML editor, change grid-row values, and watch items span different rows.
5 people found this page helpful