Nearby lessons

5 of 15

📐 CSS Grid: Rows, Columns, and Gaps

📌 What are CSS Grid Rows, Columns, and Gaps?

CSS Grid provides powerful layout capabilities, especially for two-dimensional designs.
In this section, you'll learn how to define gaps, start and end positions, and span rows or columns.

🔸 Gaps Between Items

AttributeValueDescription
column-gap20pxSets space between columns only
row-gap15pxSets space between rows only
gap10px 20pxShorthand for row-gap and column-gap

📏 Column Gap Example

column-gap: 20px adds space only between columns
Example03
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

📐 Row Gap Example

row-gap: 15px adds space only between rows
Example04
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

✨ Gap Shorthand Example

gap: 10px 20px shorthand for both row and column gaps
Example05
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output