bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Modern Layout
CSS•Modern Layout

CSS Grid Gap

CSS Grid Gaps

The space between the rows and columns in a grid container are called gaps (or gutters ).

The gaps are created between the grid rows and columns, not on the outer edges of the grid container.

The default size of the gap is 0, which means that there are no spacing between grid items.

The size of the gap can be adjusted with the following properties:

  • column-gap - Specifies the gap between grid columns
  • row-gap - Specifies the gap between grid rows
  • gap - Shorthand property for row-gap and column-gap

The CSS column-gap Property

The column-gap property specifies the gap between the columns in a grid.

Example

Formatted code
.container {
  display: grid;
  column-gap: 50px;
}

Live preview

Expected output

1 2 3 4 5

The CSS row-gap Property

The row-gap property specifies the gap between the rows in a grid.

Example

Formatted code
.container {
  display: grid;
  row-gap: 50px;
}

Live preview

Expected output

1 2 3 4 5

The CSS gap Property

The gap property is a shorthand property for row-gap and column-gap .

If a single value is provided, it applies the same gap to both rows and columns.

If two values are provided, the first value sets the row-gap , and the second value sets the column-gap .

Example

Formatted code
.container {
  display: grid;
  gap: 50px;
}

Live preview

Expected output

1 2 3 4 5

Example

Formatted code
.container {
  display: grid;
  gap: 30px 100px;
}

Live preview

Expected output

1 2 3 4 5

CSS Grid Gap Properties

PropertyDescription
column-gapSpecifies the gap between the grid columns
gapA shorthand property for row-gap and column-gap
row-gapSpecifies the gap between the grid rows

Previous

CSS Flexbox Align

Next

Responsive Web Design - Media Queries

This chapter

Overview
24

Lessons

64m

Read time

1. CSS Flexbox2. CSS Grid Layout3. Responsive Web Design4. CSS Flex Container5. CSS Grid Container6. Responsive Web Design - The Viewport7. CSS Flexbox justify-content8. CSS Grid Tracks9. Responsive Web Design - Building a Grid View10. CSS Flexbox Align11. CSS Grid Gap12. Responsive Web Design - Media Queries13. CSS Flex Items14. CSS Grid Container - Align Grid Content15. Responsive Web Design - Images16. CSS Responsive Flexbox17. CSS Grid Items18. Responsive Web Design - Frameworks19. CSS Naming Grid Items20. Responsive Web Design - Templates21. CSS Grid Items - Alignment22. CSS Grid Items - Order23. CSS 12-Column Grid Layout24. CSS @supports Rule

On this page

CSS Grid GapsThe CSS column-gap PropertyThe CSS row-gap PropertyThe CSS gap PropertyCSS Grid Gap Properties