Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsUse gap on a Grid, Flexbox, or multi-column container to set space between its tracks or items. For example, this gives a three-column grid an even 1rem gutter horizontally and vertically:
.card-list {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1rem;
}
gap affects the space between siblings, not the space around the container. Its two-value form is row-gap first, then column-gap; in Flexbox, those names map to lines and items according to flex-direction.
What does CSS gap do?
gap is a container-level shorthand for row-gap and column-gap. It sets gutters between Grid tracks, Flexbox items or lines, and multi-column boxes. Put it on the parent layout container, not on the children. See the MDN property reference.
A gap is only between participating tracks or items: it does not create an inset before the first or after the last one, and it does not add padding between a container’s border and its content.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
How do one-value and two-value syntax work?
One value applies equally to both dimensions. Two values set row spacing first and column spacing second:
.card-list {
gap: 0.75rem 1.25rem; /* row gap, then column gap */
}
That order stays the same regardless of layout mode. The visual direction of those gaps depends on the layout, especially in Flexbox.
Rank #2
How do you use gap in Flexbox?
For a row-direction flex container, column-gap separates items along a line and row-gap separates wrapped lines. Enable wrapping if you want multiple lines:
.toolbar {
display: flex;
flex-wrap: wrap;
gap: 0.75rem 1rem; /* line spacing, then item spacing */
}
For a column-direction container, row-gap separates items down the column. A one-value declaration is usually clearest:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
.stack {
display: flex;
flex-direction: column;
gap: 1rem;
}
The mapping follows flex-direction, not a permanently horizontal-versus-vertical rule: row and row-reverse use the first value between lines and the second between items; column and column-reverse use the first between items and the second between lines. Flexbox is single-line by default, so line gaps matter only when wrapping creates multiple lines. The MDN gaps guide covers the layout-specific behavior.
How does gap behave in Grid and multi-column layouts?
Grid gutters
In Grid, row and column gaps are gutters between tracks. A spanning item spans the gutter, and the gutter behaves like an empty fixed-size track when sizing the grid. For instance, three 100px columns with a 10px gap have a 320px total track-plus-gutter width when an item spans all three columns. The gaps do not add width outside the first and last tracks. justify-content or align-content can distribute additional free space between tracks, making the visible separation larger than the declared gap.
Rank #4
Multi-column gutters
In multi-column layout, column-gap sets the gutter between adjacent columns. row-gap applies when columns form multiple rows under the relevant multi-column behavior. The documented default column gutter is 1em; outside multi-column layout, normal computes to zero. Set an explicit value when consistent spacing matters. See MDN’s layout gap guide.
Which value should you choose?
- Length: Use a length such as
0.75remor12pxwhen you want predictable spacing. - Percentage: A percentage is based on the container’s content box in the relevant dimension. Its behavior during intrinsic sizing varies by layout: cyclic Grid percentages can differ between intrinsic contributions and final layout, and percentage gaps in Flexbox may be zero or ignored during intrinsic sizing before applying after sizing. If the container dimension is indefinite, do not assume percentages behave identically across Grid and Flexbox. Consult the property reference and layout guide for the specific case.
normal: This is the default. It computes to zero outside multi-column layout, where the default column gutter is1em.
The formal syntax also permits non-negative lengths, percentages, and line-width keywords. If you rely on newer syntax or support a defined browser floor, check the reference’s compatibility table rather than assuming every evolving syntax feature is implemented everywhere. MDN marks the core property Baseline and widely available, with browser availability since October 2017.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Best Value
Why does the visible spacing look larger than gap?
gap sets inter-item or inter-track spacing, but it may not be the only source of visible space. Check these together:
- The parent’s declared
gap; in a two-value declaration, confirm the first value is row gap and the second is column gap. - For Flexbox,
flex-directionandflex-wrap, which determine what the two dimensions separate. - Margins on the children and padding on the container.
justify-contentandalign-content, which can distribute extra free space between items, lines, or tracks. The MDN box alignment overview explains that interaction.- Percentage gaps when container dimensions are indefinite.
For new code, use gap, row-gap, and column-gap. Older Grid-era declarations such as grid-gap, grid-row-gap, and grid-column-gap are legacy aliases.
Or skip the browser setup
If you need a screenshot of a page to check how a layout renders, ScreenshotNeo provides a website screenshot API. One GET request returns an image or PDF; the following cURL example saves a WebP screenshot of Stripe. See the ScreenshotNeo documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with the result reported in response headers. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Recommended Free Tools
Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




