Gap utilities
Gap utilities space out the children of flex and grid containers without margins on each child.
In this page:
Syntax
<div class="d-flex gap-3">
<div>item</div>
<div>item</div>
</div>
Gap utilities
On a .d-flex or .d-grid container, .gap-3 adds equal space between children. Use .row-gap-* and .column-gap-* for one direction. In the grid system the equivalent are gutter classes g-*, gx-* and gy-*.
Note:
gap works on flex and grid containers only.
Example: Gap utilities
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
<div class="d-flex gap-3 mb-3">
<div class="bg-success text-white p-2">one</div><div class="bg-success text-white p-2">two</div><div class="bg-success text-white p-2">three</div>
</div>
<div class="d-flex flex-wrap column-gap-5 row-gap-1 border p-2">
<span class="badge text-bg-secondary">a</span><span class="badge text-bg-secondary">b</span><span class="badge text-bg-secondary">c</span>
</div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Using gap on non-flex elements
- Adding margins to every child instead
- Confusing gap with gutters
Chapter Summary
- gap-* spaces flex and grid children
- row-gap and column-gap control one axis
- Grid gutters use g-*
- No per-child margins needed
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: