Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Flexbox

The place-content property

Reference for the CSS place-content shorthand: set align-content and justify-content together to center or distribute a grid or flex layout, with examples.

The place-content property is a shorthand for align-content and justify-content. It decides how the whole set of tracks (in a grid) or lines (in a wrapped flex container) is positioned and spaced inside the container when there is spare room.

One value is applied to both axes; two values give the block-axis value first, then the inline-axis value.

CSS
.grid { place-content: center; }
.grid { place-content: start space-between; }

Try it

Centering a small grid

The four fixed-size tracks use less space than the container offers. place-content: center moves the whole block of tracks to the middle, vertically and horizontally.

Two values: block axis then inline axis

Syntax

CSS
place-content: <'align-content'> <'justify-content'>?
  • Initial value: normal (for both)
  • Applies to: block containers, flex containers and grid containers
  • Inherited: no
  • Animatable: no
  • Computed value: as specified for the longhands

Values

Value Description
start, end, center Packs the tracks or lines at the start, end or middle.
flex-start, flex-end Like start and end, in flex layout.
space-between Pushes the first and last tracks to the edges and spreads the rest evenly.
space-around Equal space around each track, so edges get half the inner gap.
space-evenly Identical space between all tracks and at both edges.
stretch Enlarges auto-sized tracks or lines to fill the container.
normal Default; behaves like stretch in grid and flex layout.

Usage notes

  • Needs free space. If the tracks already fill the container (for example 1fr columns), there is nothing to distribute and nothing visibly changes.
  • Different from place-items. place-content moves the tracks as a group; place-items aligns each item inside its own cell.
  • Single-line flex containers. align-content is ignored there, so the first value has no effect until flex-wrap: wrap creates several lines.
  • One value means both. place-content: center is the quickest way to center a fixed-size grid. Some values, such as space-between, are valid on both axes.

Browser support

Supported in all current browsers for grid and flex containers.