CSSgap Property
Example
Set the gap between rows and between columns to 50px:
gap: 50px;
}
Definition and Usage
Thegap property defines the size of the gap between the rows and between the columns in flexbox, grid or multi-column layout. It is a shorthand for the following properties:
| Default value: | normal normal |
|---|---|
| Inherited: | no |
| Animatable: | yes.Read aboutanimatableTry 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 | 14.1 | 53 |
CSS Syntax
Property Values
| Value | Description | Demo |
|---|---|---|
| row-gap | Sets the size of the gap between the rows in a grid or flexbox layout | Demo ❯ |
| column-gap | Sets the size of the gap between the columns in a grid, flexbox or multi-column layout | Demo ❯ |
| initial | Sets this property to its default value.Read aboutinitial | |
| inherit | Inherits this property from its parent element.Read aboutinherit |
More Examples
Grid layout
Set the gap between rows to 20px, and the columns to 50px in a grid layout:
display: grid;
gap: 20px 50px;
}
Flexbox layout
Set the gap between rows to 20px, and the columns to 70px in a flexbox layout:
display: flex;
gap: 20px 70px;
}
Multi-column layout
Set the gap between the columns to 50px in a multi-column layout:
columns: 3;
gap: 50px;
}
Related Pages
CSS Tutorial:CSS Grid Layout
CSS Tutorial:CSS Flexbox Layout
CSS Tutorial:CSS Muilti-column Layout
CSS Reference:row-gap property
CSS Reference:column-gap property

