Summary

The CSS align-content property aligns a flex container's lines within the flex container when there is extra space on the cross-axis.

This property has no effect on single line flexible boxes.

Initial valuestretch
Applies tomulti-line flex containers
Inheritedno
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

See Using CSS flexible boxes for more properties and information.

Syntax

/* Pack lines from the cross-axis start */
align-content: flex-start;

/* Pack lines to the cross-axis end */
align-content: flex-end;

/* Pack lines around the cross-axis center */
align-content: center;

/* Distribute lines along the cross-axis
   The first item is flush with the start, the last is flush with the end */
align-content: space-between;

/* Distribute lines evenly along the cross-axis
   Items have a half-size space on either end */
align-content: space-around;

/* Distribute lines evenly along the cross-axis
   Items all have equal space around them */
align-content: space-evenly;

/* Stretch lines to occupy the whole cross-axis */
align-content: stretch;

/* Global values */
align-content: inherit;
align-content: initial;
align-content: unset;

Values

flex-start
Lines are packed starting from the cross-start. Cross-start edge of the first line and cross-start edge of the flex container are flushed together. Each following line is flush with the preceding.
flex-end
Lines are packed starting from the cross-end. Cross-end of the last line and cross-end of the flex container are flushed together. Each preceding line is flushed with the following line.
center
Lines are packed toward the center of the flex container. The lines are flushed with each other and aligned in the center of the flex container. Space between the cross-start edge of the flex container and first line and between cross-end of the flex container and the last line is the same.
space-between
Lines are evenly distributed in the flex container. The spacing between each pair of adjacent lines is the same. The first line is flush with the cross-start edge, and the last line is flush with the cross-end edge.
space-around
Lines are evenly distributed in the flex container. The spacing between each pair of adjacent lines is the same. The empty space before the first and after the last line equals half of the space between each pair of adjacent lines.
space-evenly
Lines are evenly distributed in the flex container. The spacing between each pair of adjacent lines, the main-start edge and the first line, and the main-end edge and the last line, are all exactly the same.
stretch
Lines stretch to use the remaining space. The free-space is split equally between all the lines.

Formal syntax

flex-start | flex-end | center | space-between | space-around | space-evenly | stretch

Example

CSS

#container {
  display: flex;
  height:200px;
  width: 240px;
  flex-wrap: wrap;
  background-color: #8c8c8c;
  align-content: flex-end; /* Can be changed in the live sample */
}

div > div {
  border: 2px solid #8c8c8c;
  width: 50px;
  height: 50px;
  background-color: #a0c8ff;
}

HTML

<div id="container">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

<select id="contentAlignment">
  <option value="flex-start">flex-start</option>
  <option value="flex-end" selected>flex-end</option>
  <option value="center">center</option>
  <option value="space-between">space-between</option>
  <option value="space-around">space-around</option>
  <option value="space-evenly">space-evenly</option>
  <option value="stretch">stretch</option>
</select>

Result

Specifications

Specification Status Comment
CSS Box Alignment Module
The definition of 'space-evenly' in that specification.
Working Draft Adds the space-evenly value.
CSS Flexible Box Layout Module
The definition of 'align-content' in that specification.
Candidate Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 21.0-webkit
29.0
(Yes)-webkit
(Yes)
28.0 (28.0)[2] 11 12.10 6.1-webkit
9.0
space-evenly No support No support 52.0 (52.0) No support No support No support
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 4.4 (Yes) (Yes)-webkit
(Yes)
28.0 (28.0)[2] 11.0 12.10 7.1-webkit
9.2
space-evenly No support No support No support 52.0 (52.0) No support No support No support

[1] In addition to the unprefixed support, Gecko 48.0 (Firefox 48.0 / Thunderbird 48.0 / SeaMonkey 2.45) added support for a -webkit prefixed version of the property for web compatibility reasons behind the preference layout.css.prefixes.webkit, defaulting to false. Since Gecko 49.0 (Firefox 49.0 / Thunderbird 49.0 / SeaMonkey 2.46) the preference defaults to true.

See also

Document Tags and Contributors

 Last updated by: chrisdavidmills,