CSS gap Property
Example
Set the gap between rows and columns to 50px:
.grid-container {
gap: 50px;
}
Try it Yourself »
Definition and Usage
The gap
property defines the size of
the gap between the rows and columns. It is a shorthand for the
following properties:
Note: The gap
property was formerly known as
grid-gap
.
Default value: | normal normal |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS Box Alignment Module Level 3 |
JavaScript syntax: | object.style.gap="50px 100px" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
gap (in Grid) | 66 | 16 | 61 | 12 | 53 |
gap (in Flexbox) | 84 | 84 | 63 | 14.1 | 70 |
gap (in Multiple Columns) | 66 | 16 | 61 | Not supported | 53 |
CSS Syntax
gap: row-gap column-gap;
Property Values
Value | Description | Demo |
---|---|---|
row-gap | Sets the size of the gap between the rows in a grid layout | Demo ❯ |
column-gap | Sets the size of the gap between the columns in a grid layout | Demo ❯ |
More Examples
Example
Set the gap between rows to 20px, and the columns to 50px:
.grid-container {
gap: 20px 50px;
}
Try it Yourself »
Related Pages
CSS tutorial: CSS Grid Layout
CSS reference: The row-gap property
CSS reference: The column-gap property