Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. align-content

align-content

Specifies the spacing and alignment between rows when flex items wrap into multiple lines within a flex container. This property only takes effect when wrapping occurs with 'flex-wrap: wrap'.

Sample Code

style.css
/* Stretch rows to fill the container (default) */
.container { display: flex; flex-wrap: wrap; align-content: stretch;}

/* Align rows to the top */
.container-start { display: flex; flex-wrap: wrap; align-content: flex-start;}

/* Center the rows */
.container-center { display: flex; flex-wrap: wrap; align-content: center;}

/* Distribute rows evenly */
.container-between { display: flex; flex-wrap: wrap; align-content: space-between;}

Available Values

ValueDescription
stretchStretches each row to fill the full extent of the container along the cross axis. This is the initial value.
flex-startAligns rows to the start of the cross axis.
flex-endAligns rows to the end of the cross axis.
centerCenters rows along the cross axis.
space-betweenPlaces the first row at the start, the last row at the end, and distributes the remaining rows evenly.
space-aroundDistributes rows with equal spacing on both sides of each row.
space-evenlyDistributes rows with completely equal spacing between all rows and edges.

Specification

PropertyDetails
Initial Valuestretch
Applies toMulti-line flex containers (elements with 'flex-wrap: wrap')
InheritedNo
AnimationNot animatable (discrete)

Browser Support

Chrome Chrome
29 +
28
27
26
25
24
23
22
21
↑ Requires prefix '-webkit-'
20 and earlier ×
Firefox Firefox
28 +
27 and earlier ×
Safari Safari
9 +
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Edge Edge
12 +
IE IE
11
10 ×
9 ×
8 ×
7 ×
6 ×
Opera Opera
16 +
15
↑ Requires prefix '-webkit-'
14 and earlier ×
iOS Safari iOS Safari
9 +
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Android Android Browser
4.4 +
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop version
Firefox Android Firefox Android
Latest
Same support as desktop version

* Version information is based on MDN / Can I Use .

Description

The 'align-content' property is specified on a flex container to control the alignment of all rows along the cross axis when items wrap into multiple lines (when 'flex-wrap: wrap' causes wrapping). It has no effect when there is only a single line ('flex-wrap: nowrap').

Visual Layout of Each Value

flex-start center space-between align-items = alignment within a row A (tall) B C D align-content = placement of all rows Controls row spacing

Difference from align-items

The 'align-items' property controls how items are aligned within each row, while 'align-content' controls how the rows themselves are positioned within the container.

PropertyTargetEffect
align-itemsItems within a rowAligns the cross-axis position of each item.
align-contentAll rowsControls how multiple rows are positioned within the container.

Pattern: Grid-like Layout

Grid-like layout packed to the top with align-content: flex-start Card 1 Card 2 Card 3 Card 4 Card 5 Card 6 flex-start: packed to top, space below

/* Wrap cards and distribute evenly */
.grid-like {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start; /* Pack to the top */
    gap: 16px;
    height: 500px;
}
.card {
    flex: 0 0 calc(33.333% - 16px);
}

Checklist When It Has No Effect

If 'align-content' is not working, check the following three points.

First, check whether 'flex-wrap: wrap' is specified. If it remains 'nowrap' (the initial value), there is only a single row and the property has no effect. Second, check whether the container has a size specified along the cross axis — 'height' is required when 'flex-direction: row'. Third, check whether wrapping is actually occurring. If all items fit on a single row, the property has no effect.

Related Properties

PropertyDescription
align-itemsControls the cross-axis alignment of items within each row. The placement of all rows together is handled by 'align-content'.
flex-wrapControls wrapping. 'align-content' only takes effect when wrapping occurs with 'wrap'.
justify-contentControls item alignment along the main axis. 'align-content' is the cross-axis equivalent for row alignment.

If you find any errors or copyright issues, please .