The grid-row-gap property controls the vertical space between rows in a CSS grid layout.
01
Row gap
Vertical.
02
0 default
No space.
03
px / rem
Length units.
04
Container
Grid parent.
05
row-gap
Modern alias.
06
Between only
Not edges.
Fundamentals
Introduction
The grid-row-gap property in CSS is used to set the size of the gap (gutter) between rows in a grid layout. This property is essential for creating space between grid items, making the layout more readable and visually appealing.
Definition and Usage
Set grid-row-gap on a grid container with display: grid. It adds space only between row tracks, not on the outer top or bottom edges of the grid. While grid-row-gap has been superseded by the row-gap property in modern CSS, it is still widely supported and useful when reading older codebases.
💡
Beginner Tip
Use grid-row-gap when you want vertical spacing only. If you need both row and column spacing, use the gap shorthand instead.
Foundation
📝 Syntax
The syntax for the grid-row-gap property is simple. You can specify the gap size using any valid CSS length unit, such as px, em, %, or rem:
syntax.css
.container{grid-row-gap:length;}
Here, length can be a fixed size (e.g., 20px), a relative size (e.g., 1em), or a percentage.
Wider row gap and tighter column gap create a layout that reads clearly down the page while keeping horizontal spacing compact.
A11y
♿ Accessibility
Use adequate gap so clickable items are not too close together on touch screens.
Prefer rem units so spacing scales with user font preferences.
Do not rely on gap alone for visual grouping; use headings and landmarks.
Test zoom levels to ensure gaps remain readable at 200% zoom.
Keep contrast between items and background clear even with spacing.
🧠 How grid-row-gap Works
1
Grid rows are defined
grid-template-rows or auto-placement creates row tracks.
Template
2
grid-row-gap is set
You choose the vertical space between adjacent rows.
Gap
3
Browser inserts gutters
Empty space appears between row tracks, not on the outer top or bottom edges.
Spacing
=
▦
Cleaner row layout
Items stay aligned with consistent vertical spacing between them.
Compatibility
🖥 Browser Compatibility
The grid-row-gap property is supported in most modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera. For future-proofing, consider using row-gap in new code.
✓ Baseline · Modern browsers
grid-row-gap everywhere
Row gap in grid layouts works in all major modern browsers.
97%Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox52+ · Desktop & Mobile
Full support
Apple Safari10.1+ · macOS & iOS
Full support
Microsoft Edge16+ · 79+ Chromium
Full support
Opera44+
Full support
grid-row-gap property97% supported
Bottom line: Safe for modern projects. Prefer row-gap in new code; both work in grid layouts.
Wrap Up
🎉 Conclusion
The grid-row-gap property is a useful tool for creating space between rows in a CSS grid layout. Although it has been replaced by the row-gap property in modern CSS, understanding how to use grid-row-gap is still beneficial, especially when working with older codebases.
Experiment with different gap sizes to see how they can improve the layout and readability of your grid designs. For new code, consider using row-gap or the gap shorthand alongside this legacy property name.