Block layouts have been part of CSS since the beginning, but they’ve always lacked proper alignment controls. Now, with align-content support in block layouts, we can distribute content vertically with the same flexibility we’ve enjoyed in flex and grid.
align-content in block layouts
Baseline Widely available
Supported in Chrome: yes.
Supported in Edge: yes.
Supported in Firefox: yes.
Supported in Safari: yes.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2024
The old approaches required either flexbox or grid as a workaround. With flex, we needed multiple properties to achieve vertical centering. Grid made it a bit simpler with align-content, but still required changing the layout mode.
With the new align-content support in block layouts, we can achieve the same result while maintaining block layout semantics. No need to switch layout modes - just add align-content to your block container.
/* Old approach with flex */.container { min-height: 100vh; display: flex; flex-direction: column; justify-content: center;}/* Old approach with grid */.container { min-height: 100vh; display: grid; align-content: center;}/* New approach with align-content */.container { min-block-size: 100vh; display: block; align-content: center;}The browser will distribute the available space automatically, positioning your content in the center of the container. This works with any block container that has a defined block size.
display: flexCenters with flex
justify-content: centerdisplay: gridCenters with grid
align-content: centerdisplay: blockCenters with block
align-content: centerBrowser Support and Fallbacks
This feature requires browsers that support the latest CSS Box Alignment specification. For older browsers, you can use either the flex or grid approach as a fallback.
@supports (display: block) and (align-content: center) { .container { display: block; align-content: center; }}
/* Fallback for older browsers */.container { min-height: 100vh; display: grid; align-content: center;}The safest approach is to use @supports to provide a fallback for browsers that don’t support align-content in block layouts. This way, you can ensure a consistent experience across all browsers.
