align-content

W3C CSS Snapshot 2026

Position the grid rows together on the block axis when the grid is shorter than its container.

On this page

Syntax and values

Value or syntaxWhat it does
normal / stretchAuto-sized tracks can stretch into the remaining space.
start / end / centerAligns the grid tracks within the container.
space-betweenUses equal gaps between neighbors. The first and last sit at the edges when there is free space and more than one item or line.
space-aroundUses equal interior gaps. Each outside gap is half as large.
space-evenlyMakes the interior and outside gaps the same size.
safe center / unsafe centerThe safe modifier falls back to start when centering would cause overflow. Unsafe keeps the requested alignment. These modifiers apply to supported positional values.
baseline / first baseline / last baselineAligns first or last text baselines. baseline is the first-baseline form.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>align-content example</title>
  <style>
.layout { display: grid; width: min(100%, 320px); border: 2px solid teal; box-sizing: border-box; }
.layout > div { padding: 8px 12px; background: #def5f5; color: #123; border: 1px solid #81b9b5; box-sizing: border-box; }
.layout { width: min(100%, 320px); height: 155px; grid-template-columns: 56px 56px; grid-template-rows: 45px 45px; gap: 6px; }
.layout { align-content: end; }
  </style>
</head>
<body>
<div class="layout">
  <div class="first">A</div>
  <div class="second">B</div>
  <div>C</div>
</div>
</body>
</html>

What to expect Both rows sit near the bottom of the container in this horizontal writing mode.

Official references