16 / 21

What’s the difference between justify-content and align-content in Grid?

Understanding justify-content and align-content in CSS Grid

In CSS Grid, justify-content and align-content are used to control the alignment of the entire grid within its container when there is extra space. They work on the grid as a whole, not on individual grid items.

Key Differences
  1. 1

    justify-content aligns the grid horizontally (along the inline axis).

  2. 2

    align-content aligns the grid vertically (along the block axis).

  3. 3

    They only have an effect if the grid is smaller than its container in that axis.

  4. 4

    Common values include start, end, center, space-between, space-around, and space-evenly.

Example: Using justify-content and align-content