๐Ÿ“ CSS column-gap โ€” Complete Tutorial

๐ŸŒ 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.

>>โ€œcolumn-gap defines how much breathing room your columns should have.โ€

Note

โœ” Applies only when using Multi-Column Layout
โœ” Accepts any length value (px, rem, em, etc.)
โœ” Default gap is browser-dependent

๐Ÿ“ฆ Syntax

column-gap syntax

column-gap: normal | <length>;
ValueDescription
normalBrowser 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

If you're working with Grid or Flexbox, use gap instead of column-gap.

๐Ÿ”ฅ 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.

>>โ€œGood column spacing creates visual rhythm and makes content easier to read.โ€

Learn more โ†’MDN Docs ๐Ÿ“˜