The <grid-gap>, along with <row-gap> and <column-gap> properties, controls spacing between grid layouts. With these, we can separate elements easily without using extra margins.
The <grid-gap> property is shorthand for setting both row and column spacing. This is a simple way to make a grid neat and readable.
The following example shows how to create a two-column grid with 20px spacing between cells.
The <row-gap> and <column-gap> properties allow us to set row and column spacing independently. This is useful when aiming for different layouts.
In this example, the row spacing is 10px, while the column spacing is 30px.
Setting spacing improves the website’s visual structure and user experience. Here are some useful tips:
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.