row-gap (grid-row-gap)

The row-gap CSS property sets the size of the gap (gutter) between an element's rows.

CSS Grid Layout initially defined the grid-row-gap property. This prefixed property is being replaced by row-gap. However, in order to support browsers that implemented grid-row-gap and not row-gap for grid, you will need to use the prefixed property as in the interactive example above.

Syntax

/* <length> values */
row-gap: 20px;
row-gap: 1em;
row-gap: 3vmin;
row-gap: 0.5cm;

/* <percentage> value */
row-gap: 10%;

/* Global values */
row-gap: inherit;
row-gap: initial;
row-gap: unset;

Values

<length-percentage>
Is the width of the gutter separating the rows. <percentage> values are relative to the dimension of the element.

Formal syntax

normal | <length-percentage>

where
<length-percentage> = <length> | <percentage>

Example

HTML

<div id="grid">
  <div></div>
  <div></div>
  <div></div>
</div>

CSS

#grid {
  display: grid;
  height: 200px;
  grid-template-columns: 200px;
  grid-template-rows: repeat(3, 1fr);
  row-gap: 20px;
}

#grid > div {
  background-color: lime;
}

Result

Specifications

Specification Status Comment
CSS Box Alignment Module Level 3
The definition of 'row-gap' in that specification.
Working Draft Initial definition

Initial valuenormal
Applies tomulti-column elements, flex containers, grid containers
Inheritedno
Percentagesrefer to corresponding dimension of the content area
Mediavisual
Computed valueas specified, with <length>s made absolute, and normal computing to zero except on multi-column elements
Animation typea length, percentage or calc();
Canonical orderper grammar

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

66

571

291 2

16

161

61

521

401 3

No

53

441

281 4

10.11
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support

66

571

66

571

292

16

161

61

521

401 3

53

441

10.316.01

1. Supported as grid-row-gap.

2. From version 29: this feature is behind the Enable experimental Web Platform features preference. To change preferences in Chrome, visit chrome://flags.

3. From version 40: this feature is behind the layout.css.grid.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

4. From version 28: this feature is behind the Enable experimental Web Platform features preference.

See also

Document Tags and Contributors

Contributors to this page: rachelandrew, mfluehr, ExE-Boss
Last updated by: rachelandrew,