CSS grid-row Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout

What You’ll Learn

The grid-row property lets you control how many rows a grid item spans and where it starts and ends vertically.

01

Row span

Vertical size.

02

1 / 3

Line numbers.

03

span 2

Row count.

04

Shorthand

Start & end.

05

auto

Default flow.

06

Grid item

Child element.

Introduction

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.

Definition and Usage

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.

💡
Beginner Tip

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.

📝 Syntax

The syntax for the grid-row property combines the start and end lines of a grid item:

syntax.css
element {
  grid-row: start / end;
}
  • start — Specifies the starting grid line for the item.
  • end — Specifies the ending grid line for the item.

Longhand Syntax

grid-row-longhand.css
element {
  grid-row-start: start;
  grid-row-end: end;
}
grid-row: 1 / 3; grid-row: span 2; grid-row: 1 / -1;

Default Value

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.

Syntax Rules

  • Applies to grid items (children of a grid container), not the container itself.
  • Shorthand for grid-row-start and grid-row-end.
  • Accepts line numbers, span n, named lines, and auto.
  • The property is not inherited.
  • Negative line numbers count from the bottom of the grid.

⚡ Quick Reference

QuestionAnswer
Initial valueauto / auto
Applies toGrid items
InheritedNo
Shorthand forgrid-row-start / grid-row-end
Full-height trickgrid-row: 1 / -1;

💎 Property Values

ValueDescription
autoDefault value. The item will be placed in the next available slot
span nThe item will span n rows
line-numberThe item will start or end at the specified grid line
span n / autoThe item will span n rows from the start line
auto / span nThe item will span n rows from the end line

👀 Live Preview

Item 1 spans rows 1–2 with grid-row: 1 / 3 (highlighted):

1
2
3
4
5
6

Examples Gallery

Span two rows with line numbers, use span shorthand, build a full-height sidebar, and combine row and column placement.

🔢 Row Placement

Start with the reference example — an item spanning two rows with line numbers.

Example 1 — Span Two Rows with 1 / 3

Create a simple grid and position an item to span two rows.

grid-row-span-two.css
.item1 {
  grid-row: 1 / 3;
}
Try It Yourself

How It Works

Starting at row line 1 and ending at row line 3 makes Item 1 twice as tall as single-row items.

Example 2 — Tall Card with span 2

Make a featured card span two rows without specifying exact line numbers.

grid-row-span.css
.hero {
  grid-row: span 2;
}
Try It Yourself

How It Works

span 2 tells the hero card to cover two row tracks from its auto-placed starting position.

📈 Layout Patterns

Common real-world uses for row placement in page layouts.

Example 3 — Full-Height Sidebar

Stretch a sidebar from the first row to the last using negative line numbers.

grid-row-sidebar.css
.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
}
Try It Yourself

How It Works

grid-row: 1 / -1 fills every row track. Combined with a fixed column, the sidebar stays full height.

Example 4 — Dashboard Header Row

Place a header in row 1 and let content fill remaining rows.

grid-row-dashboard.css
.header { grid-row: 1; grid-column: 1 / -1; }
.content { grid-row: 2 / -1; grid-column: 1 / -1; }
Try It Yourself

How It Works

The header occupies row 1 across all columns. Content spans from row 2 to the last row line.

♿ Accessibility

  • Keep DOM order meaningful when row placement changes visual reading flow.
  • Do not rely on row position alone to convey meaning; use headings and labels.
  • Test keyboard tab order when tall items reorder the visual layout.
  • Use semantic HTML such as <header> and <main> alongside grid placement.
  • Verify content remains readable when items span many rows on small screens.

🧠 How grid-row Works

1

Grid rows are defined

grid-template-rows creates numbered row tracks.

Template
2

grid-row is set

You define start and end row lines or a span on a grid item.

Placement
3

Browser spans rows

The item stretches vertically across the specified row tracks.

Span
=

Precise vertical layout

Items cover exactly the rows you need for sidebars, heroes, and headers.

🖥 Browser Compatibility

The grid-row property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

grid-row everywhere

Row placement works in all major modern grid implementations.

97% Modern browser support
Google Chrome 57+ · Desktop & Mobile
Full support
Mozilla Firefox 52+ · Desktop & Mobile
Full support
Apple Safari 10.1+ · macOS & iOS
Full support
Microsoft Edge 16+ · 79+ Chromium
Full support
Opera 44+
Full support
grid-row property 97% supported

Bottom line: Safe for modern projects. Test spanning layouts across browsers for consistent rendering.

🎉 Conclusion

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.

💡 Best Practices

✅ Do

  • Use line numbers for precise row placement
  • Use span n for flexible row counts
  • Use 1 / -1 for full-height sidebars
  • Pair with grid-column for 2D layouts
  • Test responsive behavior at smaller widths

❌ Don’t

  • Apply on grid containers instead of items
  • Confuse row lines with row count
  • Forget that line numbering starts at 1
  • Break reading order without testing a11y
  • Over-span items on mobile layouts

Key Takeaways

Knowledge Unlocked

Five things to remember about grid-row

Use these points when placing items vertically.

5
Core concepts
auto 02

Default auto

One row.

Default
1/3 03

Line numbers

Start & end.

Syntax
span 04

span 2

Two rows.

Pattern
item 05

Grid item

Not container.

Scope

❓ Frequently Asked Questions

grid-row is shorthand that sets where a grid item starts and ends vertically, controlling which rows the item spans.
The default is auto / auto, which places the item in the next available cell and spans one row.
grid-row-start sets only the starting row line. grid-row is shorthand for both grid-row-start and grid-row-end.
The item starts at row line 1 and ends at row line 3, spanning two row tracks.
grid-row controls row placement only. grid-area can set both row and column placement, or assign a named area.

Practice in the Live Editor

Open the HTML editor, change grid-row values, and watch items span different rows.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful