CSS row-gap Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The row-gap property sets the size of the gutter between rows. It works on grid, flex, and multi-column containers.

It is the longhand for the row half of gap. Pair it with column-gap when you want different horizontal spacing. The property is not inherited. The initial value is normal (0 in grid and flex; 1em in multi-column).

Standard-track · Baseline Widely available.

Not experimental. Prefer row-gap over the older alias grid-row-gap (still supported as an alias).

CSS Syntax

syntax.css
row-gap: normal | <length-percentage> | initial | inherit;

Example: row-gap: 20px;. Negative values are invalid. Percentages refer to the container’s block size when that size is definite.

Property Values

ValueDescriptionTry it
normalDefault. 0 in grid/flex; 1em in multi-columnTry it
<length>Fixed gutter such as 20px or 1remTry it
<percentage>Percent of the container’s content-box block sizeTry it
initialResets to normalTry it
inheritTakes the parent’s row-gapTry it

Gaps sit between rows only — never before the first row or after the last.

How to Use row-gap

Make a multi-row container, then set the vertical gutter on that container.

  1. Set display: grid, display: flex, or a multi-column layout on the container.
  2. Ensure there is more than one row (grid tracks, flex-direction: column, or flex-wrap: wrap).
  3. Add row-gap with a length, percentage, or normal.
  4. Use column-gap or gap when you also need horizontal spacing.
PieceRequired?Role
Flex, grid, or multi-column containerYesrow-gap has no effect on a normal block box
More than one rowYesA single row shows no vertical gutter
Gap sizeYesLength, percentage, or normal

Live Preview

A two-column grid. Only row-gap changes. Column spacing stays fixed so you can see the vertical gutters clearly.

Vertical gutters change. The 12px column gap stays the same.

Sample
1
2
3
4
5
6

row-gap: 20px

CSS Examples

Each snippet focuses on row-gap. Extra styles stay minimal for study. Use Try It Yourself for a live editor.

Example 1 — Grid Row Gutters

Space only the rows. Columns keep a separate smaller gap.

CSS
<style>
  section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 20px;
    column-gap: 12px;
  }
</style>

<section>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
</section>
Try It Yourself

How It Works

  1. Make a grid. Two equal columns create multiple rows of items.
  2. Set the row gutter. row-gap: 20px adds 20px between row tracks.
  3. Keep columns separate. column-gap: 12px spaces columns without changing the row gap.
  4. Edges stay flush. No extra space before the first row or after the last.

Example 2 — Flex Column Stack

In a column flex container, row-gap spaces the stacked items.

CSS
<style>
  section {
    display: flex;
    flex-direction: column;
    row-gap: 16px;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
</section>
Try It Yourself

How It Works

  1. Stack the items. flex-direction: column places each child on its own row.
  2. Add row-gap. 16px appears between One and Two, and between Two and Three.
  3. Skip item margins. Even spacing without margin-bottom on each child.
  4. Needs modern flex gap. Flex row-gap needs Chrome 84+, Firefox 63+, or Safari 14.1+.

Example 3 — Wrapped Flex Rows

When flex items wrap, row-gap spaces the wrapped lines.

CSS
<style>
  section {
    display: flex;
    flex-wrap: wrap;
    width: 220px;
    row-gap: 16px;
    column-gap: 8px;
  }
  div {
    width: 100px;
  }
</style>

<section>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
</section>
Try It Yourself

How It Works

  1. Wrap the items. A narrow width plus flex-wrap: wrap creates two flex lines.
  2. Space the lines. row-gap: 16px sits between the wrapped rows.
  3. Space side by side. column-gap: 8px spaces items on the same line.
  4. Same idea as grid. Gutters only appear between lines, not outside them.

Edge Cases & Pitfalls

If the vertical space looks wrong, one of these is usually why.

single

One row shows nothing

With a single row of items, there is no place for a row gutter. Add tracks, wrap, or use a column flex.

normal

normal is not always zero

In grid and flex, normal is 0. In multi-column, it is 1em.

negative

Negative values are invalid

Browsers ignore a negative row-gap. Use 0 or a positive length.

margin

Do not mix with item margins for the same job

Margins plus row-gap can double the space. Prefer gap on the container for even gutters.

alias

grid-row-gap is the old name

It still works as an alias. New styles should use row-gap (works beyond grid).

Browser Support

row-gap is a browser CSS property for layout gutters. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

row-gap

Grid support since about 2017. Flex row-gap since Chrome 84, Firefox 63, Safari 14.1, and Edge 84. Internet Explorer does not support it.

97% Global support
Google Chrome 66+ grid · 84+ flex
Full support
Mozilla Firefox 61+ grid · 63+ flex
Full support
Apple Safari 12+ grid · 14.1+ flex
Full support
Microsoft Edge 16+ grid · 84+ flex
Full support
Opera 53+ grid · flex in Chromium 84+
Full support
Samsung Internet 9.2+
Full support
Internet Explorer No
Not supported
row-gap Widely supported

Bottom line: Safe for modern grid and flex. Prefer row-gap over grid-row-gap. This is not a JavaScript runtime API.

Key Takeaways

  • Role: set the gutter between rows in grid, flex, and multi-column layouts.
  • Longhand of gap: use it when only the vertical spacing should change.
  • Initial: normal — 0 in grid/flex, 1em in multi-column.
  • Between only: never adds space before the first or after the last row.

One line: row-gap is the clean way to space rows without margin tricks on every child.

Frequently Asked Questions

It sets the size of the gutter between rows in grid, flex, and multi-column layouts. Space appears only between rows, not before the first or after the last.
row-gap controls only the vertical (row) gutter. gap is the shorthand that can set both row-gap and column-gap.
The initial value is normal. That means 0 in grid and flex, and 1em in multi-column layout.
Yes. It spaces stacked flex items in a column, or spaces wrapped flex lines when flex-wrap creates more than one row.
grid-row-gap is an older alias for row-gap. Prefer row-gap in new CSS. Browsers still recognize the old name.
It is Baseline Widely available. Grid support is older (Chrome 66+, Firefox 61+, Safari 12+, Edge 16+). Flex support is later (Chrome 84+, Firefox 63+, Safari 14.1+, Edge 84+). Internet Explorer does not support it.

Next: scale

Resize elements independently of the transform list.

scale tutorial →

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.

8 people found this page helpful