The gap property sets the gutters between rows and columns. It works on grid, flex, and multi-column containers.
It is a shorthand for row-gap and column-gap. One value sets both axes. Two values set row gap first, then column gap. The property is not inherited. The initial value is normal (0 in grid and flex; 1em in multi-column).
Standard-track.
Not deprecated and not experimental. Baseline Widely available. Early grid used the alias grid-gap; prefer gap in new CSS.
Syntax
CSS Syntax
syntax.css
gap:<row-gap><column-gap>? | initial | inherit;
Each gap value is normal, a length such as 20px, a percentage, or calc().
Make a flex row.display: flex lays children in a line.
Allow wrapping.flex-wrap: wrap lets items form extra lines when needed.
Add gutters.gap: 16px spaces items and lines without fighting margins.
Two-value tip. On a row flex, gap: 8px 16px means 8px between lines and 16px between items.
Edge Cases & Pitfalls
If the spacing looks wrong, check these first.
block
Needs a flex, grid, or multi-column container
On a normal block box, gap does nothing. Set display: flex or display: grid first.
edges
No gap before the first or after the last
Gutters sit between tracks or items only. Use padding on the container for outer inset.
margin
Margins still add extra space
gap and margin stack. Large item margins can make the visual space larger than the gap value.
%
Percentages need a definite container size
Percent gaps resolve against the container content box. With an indefinite size, flex percent gaps can resolve to 0.
legacy
grid-gap is an old alias
Browsers still accept grid-gap. New code should use gap.
Compatibility
Browser Support
gap is a browser CSS property for layout gutters. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
gap
Grid support since about 2017. Flex gap since Chrome 84, Firefox 63, Safari 14.1, and Edge 84. Internet Explorer does not support it.
97%Global 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+ grid · flex in Chromium 84+
Full support
Samsung Internet7.2+
Full support
Internet ExplorerNo
Not supported
gapWidely supported
Bottom line: Safe for grid and flex in current browsers. Prefer gap over grid-gap. Multi-column containers also accept gap for column gutters.
Remember
Key Takeaways
Role: set gutters between rows and columns in flex, grid, and multi-column layouts.
Shorthand: one value for both axes; two values = row-gap then column-gap.
Not inherited. Initial value is normal (0 in grid/flex).
Prefer over item margins for even spacing between siblings.
One line:gap is the clean way to space flex or grid items between each other without margin tricks.
Frequently Asked Questions
It sets the gutters between rows and columns on grid, flex, and multi-column containers. It is a shorthand for row-gap and column-gap.
The initial value is normal. In grid and flex that means 0. In multi-column layout, normal means 1em.
gap spaces items only between each other inside the container. margin adds space around one element and can push outside the layout. Prefer gap for even item spacing in flex and grid.
Yes in modern browsers. Flex gap is Baseline Widely available (Chrome 84+, Firefox 63+, Safari 14.1+, Edge 84+). Grid support landed earlier.
gap is the shorthand. One value sets both axes. Two values set row-gap first, then column-gap. The longhands control one axis each.
It is Baseline Widely available. Grid: Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+. Flex: Chrome 84+, Firefox 63+, Safari 14.1+, Edge 84+. Internet Explorer does not support it. It is a browser CSS property, not a Node.js feature.