The row-gap property sets vertical space between rows in grid and flex layouts. It is cleaner than adding bottom margins to every child.
01
normal
Default gap.
02
px
Fixed space.
03
rem
Scalable.
04
grid
Row spacing.
05
flex
Stacked items.
06
gap
Shorthand.
Fundamentals
Introduction
The row-gap property in CSS is used to set the vertical spacing (gap) between rows in grid and flexbox layouts.
It is an essential property for controlling the layout and spacing of elements in a more manageable and visually appealing way.
Definition and Usage
Apply row-gap on the container, not on individual children. In CSS Grid, it adds space between horizontal grid tracks. In a flex column, it adds space between stacked items.
Pair row-gap with column-gap when you need different vertical and horizontal spacing, or use the gap shorthand when both axes should match.
💡
Beginner Tip
Gap properties create space between items only. They do not add outer padding around the whole container.
Foundation
📝 Syntax
The syntax for the row-gap property is straightforward. It can be applied to grid and flexbox containers to specify the space between rows.
syntax.css
container{row-gap:value;}
Here, value can be any valid CSS length unit, such as px, em, rem, %, vh, vw, etc.
Use length units like px or rem for predictable spacing.
normal is the default and usually means no extra row gap.
Percentages are relative to the container size in grid layouts.
Combine with column-gap for separate horizontal spacing.
Use gap: row column shorthand when both values are needed.
Defaults
🎯 Default Value
The default value of the row-gap property is normal, which means the browser will use its default spacing. For grid layouts, this usually means no additional space between rows.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
normal
Applies to
Grid and flex containers
Controls
Vertical space between rows
Shorthand
gap (with column-gap)
Inherited
No
Animatable
Yes (length values)
Reference
💎 Property Values
Value
Example
Description
length
row-gap: 20px;
Specifies a fixed gap between rows, such as 10px, 1em, etc.
percentage
row-gap: 10%;
Specifies a gap relative to the size of the container, such as 10%.
normal
row-gap: normal;
The browser’s default row gap, which is usually 0.
normal20px1.25rem10%
Context
When Does row-gap Matter?
row-gap is the right tool when vertical rhythm needs to be consistent:
Card grids — Separate rows of dashboard tiles without margin hacks.
Form sections — Stack fields evenly in a flex column.
Image galleries — Keep row breathing room in responsive grids.
Design systems — Use rem gaps that scale with typography.
If both row and column spacing are equal, gap: 20px is shorter than setting each longhand separately.
Preview
👀 Live Preview
This 2-column grid uses row-gap: 1rem between the two rows.
1
2
3
4
Only vertical space between rows is controlled by row-gap.
Hands-On
Examples Gallery
Start with the reference grid, compare zero vs spaced rows, use flex columns, and scale gaps with rem.
▦ Grid Row Spacing
Add vertical space between grid rows — matching the reference example.
Example 1 — Grid with row-gap
In this example, we’ll create a simple grid layout with a specified row gap.
Choose a length, percentage, or normal for vertical spacing.
row-gap
3
Browser inserts gutters
Space appears between row tracks without margins on children.
Gutters
=
★
Cleaner layouts
Even vertical rhythm in grids and stacked flex UIs with one property.
Compatibility
Browser Compatibility
The row-gap property is widely supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.
✓ Grid · Flex · Modern support
Reliable row-gap support
Current Chrome, Firefox, Safari, Edge, and Opera support row-gap in grid and flex layouts.
97%Modern browser support
Google Chrome57+ grid · 84+ flex
Full support
Mozilla Firefox52+ grid · 63+ flex
Full support
Apple Safari10.1+ grid · 14.1+ flex
Full support
Microsoft Edge16+ grid · 84+ flex
Full support
Opera44+ · Modern versions
Full support
Testing tip
Flexbox gap support is slightly newer than grid gap. Test stacked flex layouts in Safari if you support older iOS versions.
row-gap property97% supported
Bottom line:row-gap is widely supported for grid and modern flex layouts.
Wrap Up
Conclusion
The row-gap property is a powerful tool for web developers looking to control the vertical spacing between rows in grid and flexbox layouts.
By customizing the row gap, you can create more visually appealing and well-structured layouts. Experiment with different values to see how this property can enhance the look and feel of your web projects.