VOOZH about

URL: https://www.geeksforgeeks.org/css/css-grid-gap-property/

⇱ CSS grid-gap Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CSS grid-gap Property

Last Updated : 8 Dec, 2025

The grid-gap property sets the size of the gap between rows and columns in a grid layout, allowing you to easily control the spacing between grid items in both horizontal and vertical directions.

It is a shorthand property for the following properties: 

  • grid-column-gap property
  • grid-row-gap property

Syntax:

grid-gap: grid-row-gap grid-column-gap;

Property Values:

  • grid-row-gap: Sets the size of the gap between the rows in a grid layout. The default value is 0
  • grid-column-gap: Sets the size of the gap between the columns in a grid layout. The default value is 0.

Different Examples of CSS Grid Gap Property

Example 1:  In this example, we are using the CSS grid-gap property to give a gap between the row and columns.

Output:

👁 Image

Example 2:  In this example we are using the css grid gap property to give gap between the row and columns.

Output:

👁 Image

The CSS grid-gap property is useful for creating visually appealing and well-spaced grid layouts. By understanding and utilizing the grid-gap, grid-row-gap, and grid-column-gap properties, developers can achieve precise control over the spacing between grid items, enhancing the overall design and usability of their web pages. Ensure cross-browser compatibility and consider the supported browser versions when implementing this property to maintain a consistent user experience across different platforms.

Comment