liveBook · Manning

Align-content

As explained in Web Design Playground

A CSS property that aligns flex lines or wrapped content within a flex container on the cross axis when extra space is available.

When a flex container wraps its items into more than one row or column, align-content decides where those whole lines sit on the cross axis. Think of each line as a shelf: this property moves or spaces the shelves, rather than moving the items on a shelf. section 12.2

It is a container property. align-items handles individual items along the cross axis; align-content handles the collection of wrapped lines. If there is only one line, there are no multiple lines to arrange. section 12.18 section 12.2

container {
    display: flex;
    align-content: stretch|center|flex-start|flex-end|space-between|space-around;
}

Use align-content on a flex container, choosing one of six values for its wrapped lines. section 12.2

Choose a value based on the layout you want:

  • stretch is the default and expands wrapped lines along the cross axis to fill the container height. section 12.2
  • center places the lines in the middle; flex-start and flex-end place them at the beginning or end of the cross axis. section 12.2
  • space-between puts the first and last lines at opposite ends and distributes the remaining lines evenly between them. section 12.2
  • space-around gives each line space on both sides, leaving one unit at the outer edges and two units between neighboring lines. section 12.2

A quick layout experiment

Make a flex container, allow its items to wrap, and try changing align-content from center to space-between. Watch the rows move as groups along the cross axis. Then try stretch and notice that writing align-content: stretch is optional because it is already the default. section 12.2 section 12.2

A useful check: are you arranging items, or are you arranging rows or columns of items? Pick align-items for the first job and align-content for the second. section 12.18 section 12.2

How Web Design Playground covers it

How deep it goes
Defines six values and their visible line-placement effects, without detailing underlying layout mechanics.
Examples
Uses figures and an interactive Playground to compare align-content values on horizontal main-axis containers.
What it assumes
Introduces line arrangement after flex containers and wrapping, without stating further prerequisites.
What you can do after
Apply it via CSS to position or distribute wrapped flex lines on the cross axis.
How it connects
Distinguishes align-content from flex-wrap, align-items, and justify-content in Flexbox layout.

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 Web Design Playground. The section links point to the parts of the book it draws on.