π What is grid-row?
grid-row is a CSS Grid item property used to control thevertical placement of an item within the grid. With this property, you can choose where an item starts and ends across grid row lines β allowing you to create tall cards, hero blocks, sidebars, and complex magazine-style layouts.
π Shorthand For
- grid-row-start
- grid-row-end
Meaning:grid-row: start / end;
π― Basic Syntax
grid-row Syntax
grid-row: <start-line> / <end-line>;π§ͺ Example: Spanning Multiple Rows
Two Row Span
.item {
grid-row: 1 / 3;
/* Starts at row line 1 and ends before line 3 β spans 2 rows */
}
π₯ Using the span Keyword
The span keyword allows an item to extend across a specific number of rows, without needing to specify exact line numbers.
Using span
.item {
grid-row: span 3;
/* Span 3 rows from wherever it is placed */
}Note
π Practical Example
Sidebar + Content Layout
.container {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: repeat(4, 150px);
gap: 20px;
}
.sidebar {
grid-row: 1 / 5; /* full height over 4 rows */
}
.content {
grid-row: 1 / 3; /* spans first 2 rows */
}
.widget {
grid-row: 3 / 5; /* bottom section */
}This creates a sidebar spanning all rows, with content and widgets arranged vertically.
π§ Understanding Grid Row Lines

| Expression | Meaning |
|---|---|
| 1 / 2 | Occupies only the first row |
| 1 / 4 | Spans 3 rows: 1 β 2 β 3 |
| 2 / 5 | Starts at row 2, spans through row 4 |
| span 2 | Spans 2 rows from its current line |
π§© Combining grid-row with grid-column
Large Hero Section
.hero {
grid-column: 1 / 4;
grid-row: 1 / 3;
}This gives you a hero component spanning multiple rows and columns.
π± Responsive Example
Responsive grid-row Usage
.card {
grid-row: span 2; /* taller on mobile */
}
@media (min-width: 900px) {
.card {
grid-row: span 1; /* shorter on desktop */
}
}Items grow vertically on smaller screens and shrink on larger ones.
β οΈ Common Mistakes
- Using row numbers that donβt exist
- Expecting grid-row to work on the grid container (only grid items!)
- Forgetting that the end line is exclusive (the item stops before that line)
- Using fixed height rows (px) and expecting flexibility
Note
π₯ Summary
grid-row gives you full control over the vertical positioning and height of grid items. Whether spanning multiple rows or creating a tall sidebar layout, this property unlocks the true 2D power of CSS Grid.
Learn more βMDN Docs π