← Back to properties
CSS Property
gap
SpacingSets the spacing between rows and columns in flex and grid containers.
Syntax
gap: value;
Example
gap: 1rem;
Common use cases
- Spacing between grid cells
- Spacing between flex items
- Replacing margin hacks in layouts
Practical developer insight
gap replaces the old grid-gap — it now works in flexbox too. No need for margin workarounds.