Course contentsShow
← Web Development
Lesson 278 of 2,9825. FlexboxFree lesson

align-content: Multi-Line Cross Axis Distribution

Control spacing between flex lines when wrapping occurs using align-content (only applies with multiple lines).

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 axis
  • flex-end – Lines pack to the end
  • center – Lines cluster in the middle
  • space-between – First line at start, last at end, equal space between
  • space-around – Equal space around each line (half-size gaps at edges)
  • space-evenly – Perfectly equal space everywhere, including edges
  • stretch (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 line
  • align-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.