What You'll Learn
You'll learn how to control the spacing between multiple lines of flex items when they wrap onto several rows or columns.
When align-content Kicks In
Remember align-content from lesson 262? It only works when your flex container has multiple lines — meaning you've used flex-wrap: wrap or flex-wrap: wrap-reverse and your items have actually wrapped.
Think of it like organizing shelves in a bookcase. If you only have one shelf of books, you can't adjust spacing between shelves. But with multiple shelves, you can decide: should they be evenly spaced? Pushed to the top? Centered vertically in the bookcase? That's what align-content does for wrapped flex lines.
How It Works
align-content distributes flex lines (not individual items) along the cross axis:
flex-start– Lines pack to the start of the cross axisflex-end– Lines pack to the endcenter– Lines cluster in the middlespace-between– First line at start, last at end, equal space betweenspace-around– Equal space around each line (half-size gaps at edges)space-evenly– Perfectly equal space everywhere, including edgesstretch(default) – Lines stretch to fill the container
If you have no wrapping (single line), align-content has no effect — use align-items instead.
The Key Difference
align-items: Aligns individual items within their linealign-content: Aligns entire lines within the container (multi-line only)
Key Takeaway: align-content controls how multiple wrapped lines of flex items distribute along the cross axis, giving you powerful control over multi-line flex layouts — but it requires wrapping to be active.