CSS Master Code Examples: Chapter 5

Back to chapter demo list

Adding gutters with the gap property

Grid items do not have space between them by default. Instead we need to add gaps or gutters using the column-gap and row-gap properties. We can also use the gap shorthand property.

Note that some browsers that support grid do not support these properties yet. You can use the older, grid-column-gap and grid-row-gap properties for those browsers. We can also use the gap shorthand property (or its grid-gap predecessor).

Related specification: CSS Grid Layout Module Level 1.

Grid item A
Grid item B
Grid item C

Grid item D

This grid item contains more content than its siblings.

Grid item E
Grid item F
Grid item G
Grid item H
Grid item I
Grid item J