🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS Grid Gap

Control spacing in your layouts. Learn to use the gap property to separate rows and columns.

grid-gap.css
.container {
display: grid;
gap: 20px;
}
🍱
grid-gap.html
1 / 8
🏗️

Tutor:The `gap` property (formerly `grid-gap`) creates space between rows and columns in a grid layout. It creates 'gutters' without adding margin to the outer edges.


Grid Mastery

Unlock nodes by learning spacing and layout.

Concept 1: The Gap Property

The gap property (formerly grid-gap) defines the size of the gap between the rows and columns. It effectively sets the gutter size.

System Check

What does the gap property do?


Community Holo-Net

Share Layouts

Created an interesting grid system? Share your code and patterns.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Grid Gap

Author

Pascual Vila

Frontend Instructor.

The gap property (formerly known as grid-gap) is a shorthand CSS property used to define the gutters or spaces between rows and columns in grid and flexbox layouts.

The Syntax

The syntax is straightforward. You can define a single value for both axes or separate values for rows and columns.

/* One value: row and column gap are 20px */
gap: 20px;

/* Two values: row gap is 10px, column gap is 50px */
gap: 10px 50px;

Row and Column Gap

If you need to be explicit, you can use the longhand properties:

  • row-gap: Sets the space between rows.
  • column-gap: Sets the space between columns.

Legacy Support: grid-gap

In earlier versions of the CSS Grid specification, this property was called grid-gap. While modern browsers support both, gap is the standard and should be preferred as it also works with Flexbox.

Grid Gap Glossary

gap
A shorthand property for row-gap and column-gap. It defines the size of the gutters between rows and columns.
row-gap
Defines the size of the gap between the rows in a grid layout.
column-gap
Defines the size of the gap between the columns in a grid layout.
grid-gap
Legacy name for the gap property. Still supported by browsers but deprecated in favor of gap.