justify-items

W3C CSS Snapshot 2026

Set the default inline-axis alignment of items in their cells. This is left-to-right or right-to-left in horizontal writing modes.

On this page

Syntax and values

Value or syntaxWhat it does
normalBehaves like stretch for most auto-sized grid items. Items with an intrinsic size or aspect ratio normally align to start.
stretchFills the cell along the alignment axis when the item’s size on that axis is auto.
start / end / centerAligns the item at the logical start, end, or center of its cell.
self-start / self-endUses the item’s writing direction for the aligned edge.
baseline / first baseline / last baselineAligns first or last text baselines. baseline is the first-baseline form.
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.
left / rightUses a physical side. legacy values support inherited horizontal alignment for legacy markup.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>justify-items 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 { grid-template-columns: 1fr 1fr; grid-template-rows: 60px 60px; }
.layout { justify-items: center; }
  </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 A, B, and C sit at the horizontal centers of their cells.

Official references