Gap
The CSS gap property specifies the spacing between rows and columns or between items in a layout container.
Tiny CSS Projects
The CSS gap property is a shorthand property that sets the spacing between rows and columns in a grid or other layout.
- How it is used
- Adds consistent space between grid tracks or flex items in cards, description lists, buttons, and responsive layouts.
- How deep it goes
- Defines the shorthand, value order, defaults, and outer-edge behavior, then applies it in grid and flex examples.
- Examples
- Uses 20-pixel grid gutters, one-rem card spacing, 12-pixel profile-statistic spacing, and a one-character button icon gap.
- What you can do after
- Apply it via CSS to space grid or flex contents without adding space at the container’s outer edges.
CSS in Depth, Second Edition
The CSS gap property specifies the spacing between rows and columns in layout containers such as flex and grid containers.
- How it is used
- Spaces flex and grid items while keeping the layout container responsible for consistent gutters.
- How deep it goes
- Explains single- and two-value spacing, unit choices, reuse, and interaction with margins, without descending into browser layout internals.
- Examples
- Demonstrates navigation menus, responsive navbar spacing, flex tile rows, and a six-item grid.
- What you can do after
- Apply it in CSS to build consistent gutters in flex and grid layouts and choose suitable spacing units.
Also covered in
- Vanilla WebIn early access (MEAP)
- Web Design Playground, Second Edition
What to know first
- containerA software container is an isolated execution environment that packages an application and its dependencies, typically sharing the host operating-system kernel.
- flexboxFlexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
- CSS GridCSS Grid is a CSS layout system for arranging elements in two-dimensional rows and columns.
Related concepts
- flexboxused by · Flexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
- column-gapuses · The CSS column-gap property specifies the space between columns in a layout.
- margin propertycontrasts with · The CSS margin property specifies the outer space around an element’s border, separating it from neighboring content.
- @propertykind of · The CSS @property at-rule registers a custom property by defining its syntax, inheritance behavior, and initial value.
- row-gapuses · The CSS row-gap property specifies the space between rows in a grid or other layout container.
- flex containerconfigures · A flex container is an element whose children are laid out as flex items according to the CSS Flexible Box Layout model.
Questions about gap
What is gap?
The CSS gap property specifies the spacing between rows and columns or between items in a layout container.
Which Manning books explain gap?
Tiny CSS Projects and CSS in Depth, Second Edition.
What should I know before learning gap?
Manning books that teach gap usually introduce container, flexbox and CSS Grid first.
What is the difference between gap and margin property?
The CSS gap property specifies the spacing between rows and columns or between items in a layout container. The CSS margin property specifies the outer space around an element’s border, separating it from neighboring content.
What is gap a kind of?
Gap is a kind of @property. The CSS @property at-rule registers a custom property by defining its syntax, inheritance behavior, and initial value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

