9.4 · Layout

Center anything: align-content on blocks

Vertically center content in a plain block, without flex or grid.

For years, centering vertically meant switching to flexbox or grid, which changes how all the children lay out. align-content now works in ordinary block layout too.

One line, align-content: center, centers the content of a block with a height. Margins, floats and text flow keep working as before.

Before
.box {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
Now
.box {
  align-content: center;
}