๐ What Is column-gap?
The column-gap property (also known as gap between columns) controls the **space between columns** in a multi-column layout. It works similar to gap in Grid/Flexbox but specifically for CSS Multi-Column Layout.
Note
โ Accepts any length value (px, rem, em, etc.)
โ Default gap is browser-dependent
๐ฆ Syntax
column-gap syntax
column-gap: normal | <length>;| Value | Description |
|---|---|
| normal | Browser default gap (usually around 1em) |
| <length> | Custom gap size such as 20px, 1.5rem, 5% |
๐ 1. Basic Example โ Add Space Between Columns
Two columns with gap
.content {
column-count: 2;
column-gap: 40px;
}Creates a 40px space between the two columns.
๐ 2. Using normal (Browser Default)
Default column gap
.article {
column-count: 3;
column-gap: normal;
}Lets the browser decide the best spacing (usually ~1em).
๐ 3. Using Small Gaps
Small gap
.narrow {
column-count: 3;
column-gap: 10px;
}Useful for compact layouts where space is limited.
๐ 4. Extra-Wide Column Gaps
Wide layout
.wide {
column-count: 3;
column-gap: 80px;
}Creates spacious, magazine-style layouts.
๐ 5. column-gap With column-rule
Gap + rule
.content {
column-count: 2;
column-gap: 50px;
column-rule: 2px solid #ccc;
}Gap controls spacing, while column-rule draws a divider line.
๐ 6. Responsive Column Gaps
Responsive gap
.responsive {
column-count: 3;
column-gap: 40px;
}
@media (max-width: 700px) {
.responsive {
column-gap: 20px;
}
}
@media (max-width: 500px) {
.responsive {
column-gap: 10px;
}
}Adjust gaps based on screen width for better readability.
๐ 7. Combining With column-width
Width + gap
.text {
column-width: 200px;
column-gap: 30px;
}Browser decides how many columns fit, and column-gap controls spacing.
๐ 8. Using column-gap in Masonry-Style Image Gallery
Gallery
.gallery {
column-count: 4;
column-gap: 1.5rem;
}
.gallery img {
width: 100%;
margin-bottom: 1.5rem;
}Creates Pinterest-like layouts with consistent spacing.
๐งช Real-World Examples
1๏ธโฃ Newspaper Column Layout
Newspaper layout
.news {
column-count: 3;
column-gap: 40px;
}2๏ธโฃ Multi-Column Footer Links
Footer columns
.footer-links {
column-count: 4;
column-gap: 25px;
}3๏ธโฃ FAQ Layout With Two Columns
FAQ layout
.faq {
column-count: 2;
column-gap: 50px;
}โ ๏ธ Common Mistakes
- โ Expecting column-gap to affect Grid or Flex layouts (it does not)
- โ Using very small gaps โ decreases readability
- โ Using percentage gaps inside narrow containers โ unpredictable spacing
Note
๐ฅ Summary
column-gap defines the spacing between columns in a multi-column layout. It gives you precise control over readability, spacing style, and layout density. Perfect for magazines, blogs, galleries, and documentation designs.
Learn more โMDN Docs ๐