Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Flexbox

The row-gap property

Reference for the CSS row-gap property: set the space between rows in grid layouts and between wrapped lines in flexbox, with live examples and usage notes.

The row-gap property sets the space between rows. In a grid, that is the gutter between row tracks. In a flex container that wraps, it is the space between flex lines. It is one half of the gap shorthand; the other half is column-gap.

The gap only appears between rows, not above the first row or below the last one.

CSS
.list { display: grid; row-gap: 1.5rem; }

Try it

Row gaps in a grid

The pink background of the container shows through the wide 24px row gaps and the narrow 4px column gap.

Syntax

CSS
row-gap: normal | <length-percentage>;
  • Initial value: normal
  • Applies to: multi-column containers, flex containers and grid containers
  • Inherited: no
  • Animatable: yes, as a length or percentage
  • Computed value: as specified, with lengths made absolute

Values

Value Description
<length> A non-negative length such as 20px or 1.5rem.
<percentage> A percentage of the container's content-box height. If that height depends on the content (for example height: auto), percentages are unreliable, so prefer lengths.
normal No gap in grid and flex layout.

Usage notes

  • Flexbox. In a single-line flex container there are no row boundaries, so row-gap has no visible effect until flex-wrap: wrap creates several lines.
  • Column direction. With flex-direction: column, items stack vertically, so row-gap spaces the items in a stack and column-gap spaces the wrapped stacks.
  • Multi-column. Row gaps do not apply between columns of text; use column-gap for those.
  • Shorthand. gap: 20px 8px sets row gap 20px and column gap 8px. Write row-gap alone when you want to change only one direction without touching the other.

Browser support

Supported in all current browsers for grid and flexbox.