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

Multi-Line Alignment with align-content

Distributing space between flex lines when items wrap across multiple rows or columns.

Multi-Line Alignment with align-content

What you'll learn: How to distribute space between multiple lines of flex items when they wrap onto new rows or columns.

The Core Idea

When you use flex-wrap: wrap or flex-wrap: wrap-reverse, your flex items can break across multiple lines. The align-content property controls how those lines themselves are spaced along the cross axis.

Think of it like organizing shelves in a bookcase. align-items arranges books on each individual shelf, but align-content decides how the shelves themselves are distributed within the entire bookcase—should they be packed at the top, spread evenly, or centered?

Important: align-content only works when items wrap across multiple lines. If everything fits on one line, this property has no effect.

How align-content Works

This property accepts several values:

  • flex-start — Lines pack at the start of the cross axis
  • flex-end — Lines pack at the end
  • center — Lines center in the container
  • space-between — First line at start, last at end, equal space between
  • space-around — Equal space around each line
  • space-evenly — Equal space between all lines and edges
  • stretch (default) — Lines stretch to fill available space

The Key Difference

Remember: align-items aligns individual items within their line, while align-content aligns the lines themselves within the container. You need both multiple lines (wrapping) and extra space on the cross axis for align-content to show its effect.

Key Takeaway: align-content distributes space between wrapped flex lines along the cross axis, controlling how multiple rows or columns are positioned within the flex container.