liveBook · Manning

Align-content

As explained in CSS in Depth, Second Edition

The CSS align-content property distributes grid tracks or flex lines along the container's block or cross axis when free space is available.

Use align-content when a flex container wraps or when a grid’s tracks do not fill the container. It distributes rows, flex lines, or grid tracks along the cross or vertical axis, using the available free space. section 4.4.1 section 5.6

Distribute unused grid space

A grid container with height: 1200px and four 200px rows defines 800px of tracks, leaving 400px available. Set align-content to start, end, center, stretch, space-between, space-around, or space-evenly to control where that space goes. The spacing values differ in whether space appears between tracks, at the edges, or both. section 5.6

Choose the value according to the visible result you need:

  • Use start or end to place tracks at the beginning or end of the container; use center to place them in the middle. section 5.6
  • Use stretch to resize tracks to fill the container; use space-between, space-around, or space-evenly to distribute free space. section 5.6
  • In a wrapping flex container, apply the property to spacing between flex lines along the cross axis. For single-line flex layouts, this row-spacing role does not apply. section 4.4.1
  • Pair align-content with justify-content when controlling both axes; use place-content as the shorthand for both properties. section 4.4.1 section 5.6

How CSS in Depth, Second Edition covers it

How deep it goes
Explains the property through flex and grid behavior, supported values, free-space calculations, and a concrete grid example.
Examples
Uses a 1200px grid containing four 200px rows to demonstrate distribution of 400px of unused space.
What it assumes
Assumes familiarity with flex containers, grid containers, axes, tracks, and available free space.
What you can do after
Apply it via CSS to position, stretch, or distribute wrapped flex lines and grid tracks within available container space.
How it connects
Connects align-content with flex-wrap, grid layout, justify-content, align-items, and place-content.

Also explained in

Compare how 3 books explain align-content →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.