justify-self

W3C CSS Snapshot 2026

Override the inline-axis alignment for one grid item.

On this page

Syntax and values

Value or syntaxWhat it does
autoUses the container’s justify-items alignment in normal grid layout.
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.

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-self 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 .second { justify-self: 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 B hugs the inline end of its cell. A and C keep the default alignment.

Official references