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
Code Example
PREVIEW READY
Loading Editor...
Live Preview

πŸ“ Row Gap Example

row-gap: 15px adds space only between rows
Code Example
PREVIEW READY
Loading Editor...
Live Preview

✨ Gap Shorthand Example

gap: 10px 20px shorthand for both row and column gaps
Code Example
PREVIEW READY
Loading Editor...
Live Preview
Keep Going!CSS - Grid Container