![]() |
VOOZH | about |
The CSS gap property defines the spacing (or "gap") between rows and columns in layouts such as Flexbox, Grid, or multi-column layouts. It simplifies the process of creating consistent spacing by combining row-gap and column-gap into one property. You can specify the gap using length units (e.g., px, em) or percentages.
Syntax:
gap: <row-gap> <column-gap>| Property Value | Description |
|---|---|
| <length> | Specifies the spacing using length units like em, px, etc. For example: gap: 10px 20px. |
| <percentage> | Specifies the spacing using percentage units. For example: gap: 50%. |
Here are examples of the CSS gap property to illustrate its use in layouts:
In this example we are using CSS Grid with specified row and column gaps (gap: 20px 50px) for layout spacing between grid items (col divs).
Output:
In this example we are using CSS Grid with a row gap specified as a percentage (gap: 20%) for layout spacing between grid items (col divs) within each row (row divs).
Output:
Note: Older browser versions may have limited support, so itβs always recommended to test for compatibility across different browsers.