CSS grid-column-gap Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout

What You’ll Learn

The grid-column-gap property controls the horizontal space between columns in a CSS grid layout.

01

Column gap

Horizontal.

02

0 default

No space.

03

px / rem

Length units.

04

Container

Grid parent.

05

column-gap

Modern alias.

06

Between only

Not edges.

Introduction

The grid-column-gap property in CSS is used to define the space (or gap) between the columns in a grid layout. This property helps in creating a visually appealing and organized structure for grid-based layouts by ensuring consistent spacing between columns.

Definition and Usage

Set grid-column-gap on a grid container with display: grid. It adds space only between column tracks, not on the outer left or right edges of the grid. For modern projects, column-gap is the standard name, but grid-column-gap behaves the same way in grid layouts.

💡
Beginner Tip

Use grid-column-gap when you want horizontal spacing only. If you need both row and column spacing, use the gap shorthand instead.

📝 Syntax

The syntax for the grid-column-gap property is simple and accepts a length value:

syntax.css
.container {
  grid-column-gap: value;
}

Here, value can be any valid CSS length unit, such as px, em, %, rem, etc.

Basic Example

grid-column-gap-basic.css
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: 20px;
}
grid-column-gap: 20px; grid-column-gap: 1.5rem; column-gap: 24px;

Default Value

The default value of the grid-column-gap property is 0. This means that, by default, there is no space between the columns in a grid layout.

Syntax Rules

  • Applies to grid containers only, not individual grid items.
  • Accepts length and percentage values.
  • Legacy alias of column-gap in grid layouts.
  • The property is not inherited.
  • Gap appears only between columns, not on the container edges.

⚡ Quick Reference

QuestionAnswer
Initial value0
Applies toGrid containers
InheritedNo
ControlsHorizontal gap between columns
Modern equivalentcolumn-gap

💎 Property Values

ValueDescription
lengthA length value specifying the size of the gap between columns, such as 10px, 1em, 2rem, etc.
percentageA percentage value relative to the size of the grid container

👀 Live Preview

Three columns with grid-column-gap: 1rem between them:

1
2
3

Examples Gallery

Add 20 pixels of column gap, compare with no gap, try rem units, and combine with row gap for asymmetric spacing.

🔢 Column Spacing

Start with the reference example — a three-column grid with 20px column gap.

Example 1 — 20px Column Gap

Create a simple grid layout with a column gap of 20 pixels.

grid-column-gap-20px.css
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: 20px;
}
Try It Yourself

How It Works

Each column track stays the same width, but 20px of empty space appears between adjacent columns.

Example 2 — No Gap vs Column Gap

See how column gap improves readability compared to columns touching each other.

grid-column-gap-compare.css
.no-gap { grid-column-gap: 0; }
.with-gap { grid-column-gap: 24px; }
Try It Yourself

How It Works

Without gap, columns sit flush together. Adding grid-column-gap creates breathing room between items.

📈 Spacing Patterns

Use relative units and combine with row gap for flexible layouts.

Example 3 — rem for Scalable Gap

Use rem units so column gap scales with root font size.

grid-column-gap-rem.css
.grid-container {
  grid-template-columns: repeat(4, 1fr);
  grid-column-gap: 1.5rem;
}
Try It Yourself

How It Works

1.5rem gap grows or shrinks when the user changes their default font size, keeping spacing accessible.

Example 4 — Column Gap with Row Gap

Set column and row spacing independently for a card grid.

grid-column-gap-asymmetric.css
.card-grid {
  grid-column-gap: 24px;
  grid-row-gap: 12px;
}
Try It Yourself

How It Works

Wider column gap and tighter row gap create a layout that reads clearly across rows while keeping vertical rhythm compact.

♿ Accessibility

  • Use adequate gap so clickable items are not too close together on touch screens.
  • Prefer rem units so spacing scales with user font preferences.
  • Do not rely on gap alone for visual grouping; use headings and landmarks.
  • Test zoom levels to ensure gaps remain readable at 200% zoom.
  • Keep contrast between items and background clear even with spacing.

🧠 How grid-column-gap Works

1

Grid columns are defined

grid-template-columns creates the column tracks.

Template
2

grid-column-gap is set

You choose the horizontal space between adjacent columns.

Gap
3

Browser inserts gutters

Empty space appears between column tracks, not on the outer edges.

Spacing
=

Cleaner column layout

Items stay aligned with consistent horizontal spacing between them.

🖥 Browser Compatibility

The grid-column-gap property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

grid-column-gap everywhere

Column gap in grid layouts works in all major modern browsers.

97% Modern browser support
Google Chrome 57+ · Desktop & Mobile
Full support
Mozilla Firefox 52+ · Desktop & Mobile
Full support
Apple Safari 10.1+ · macOS & iOS
Full support
Microsoft Edge 16+ · 79+ Chromium
Full support
Opera 44+
Full support
grid-column-gap property 97% supported

Bottom line: Safe for modern projects. Prefer column-gap in new code; both work in grid layouts.

🎉 Conclusion

The grid-column-gap property is an essential tool for web developers working with grid layouts. By specifying the space between columns, you can create a more organized and visually pleasing layout.

Experiment with different gap values to see how they can enhance the design and usability of your grid-based web projects. For new code, consider using column-gap or the gap shorthand alongside this legacy property name.

💡 Best Practices

✅ Do

  • Set gap on the grid container
  • Use rem for accessible scaling
  • Pair with grid-row-gap when axes differ
  • Prefer gap when both axes match
  • Test touch targets with adequate spacing

❌ Don’t

  • Apply on grid items instead of containers
  • Use margins when gap solves spacing cleanly
  • Expect gap on container outer edges
  • Use tiny gaps on mobile touch layouts
  • Forget the modern column-gap alias

Key Takeaways

Knowledge Unlocked

Five things to remember about grid-column-gap

Use these points when spacing grid columns.

5
Core concepts
0 02

Default 0

No space.

Default
20px 03

Length

px or rem.

Syntax
between 04

Between only

Not edges.

Behavior
column 05

column-gap

Modern name.

Alias

❓ Frequently Asked Questions

grid-column-gap sets the horizontal space between columns in a CSS grid container.
The default value is 0, which means there is no space between columns unless you set a gap.
grid-column-gap sets only column spacing. gap is shorthand for both row-gap and column-gap together.
Yes. column-gap is the modern standard name. grid-column-gap is the legacy grid-specific alias and still works in browsers.
No. Gap applies only between columns, not between the grid and the container edges.

Practice in the Live Editor

Open the HTML editor, change grid-column-gap values, and see how column spacing updates.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful