Flexbox & Grid

justify-items

Set the default inline-axis alignment of items inside their grid areas.

Overview

ClassDeclarations
justify-items:normaljustify-items: normal;
justify-items:baselinejustify-items: baseline;
justify-items:leftjustify-items: left;
justify-items:centerjustify-items: center;
justify-items:rightjustify-items: right;
justify-items:stretchjustify-items: stretch;
justify-items:legacyjustify-items: legacy;
justify-items:startjustify-items: start;
justify-items:endjustify-items: end;
justify-items:flex-startjustify-items: flex-start;
justify-items:flex-endjustify-items: flex-end;
justify-items:self-startjustify-items: self-start;
justify-items:self-endjustify-items: self-end;
justify-items:<value>justify-items: <value>;

Examples

Align grid items inline

Use justify-items:center to center each grid item in its own area along the inline axis. These two equal columns are wider than their labels; the 160px row keeps the area height visible while items-start holds the labels at the top.

Align grid items inline
Two equal grid columns keep their track sizes. Alignment changes each item’s inline position or automatic width inside its own area.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px items-start justify-items:center gap-md w:17.5rem max-w:100%">  <div id="target" class="p-sm">Alpha</div>  <div id="peer" class="p-sm">Beta</div></div>
Generated CSS
@layer utilities {  .grid {    display: grid  }  .justify-items\:center {    justify-items: center  }}

This sets the default for children with justify-self:auto. It does not distribute the tracks; use justify-content for that.

Stretch automatic-width items

justify-items:stretch fills the inline size of each grid area when the item’s width is automatic. The blue label fills its first column; the violet label keeps its explicitly set 80px width.

Stretch automatic-width items
Two equal grid columns keep their track sizes. Alignment changes each item’s inline position or automatic width inside its own area.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px items-start justify-items:stretch gap-md w:17.5rem max-w:100%">  <div id="target" class="p-sm">Auto width</div>  <div id="peer" class="w:5rem p-sm">80px</div></div>

Minimum and maximum widths still constrain stretching. Use justify-self to override this default for one item.

Apply conditionally

Use conditional queries to change alignment at a real viewport width. The automatic-width labels fill their columns by default. From sm, each label takes its intrinsic width and centers within the same grid area.

Apply conditionally
justify-items: Apply conditionally controls
Two equal grid columns keep their track sizes. Alignment changes each item’s inline position or automatic width inside its own area.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px items-start justify-items:stretch gap-md w:17.5rem max-w:100% justify-items:center@sm">  <div id="target" class="p-sm">Alpha</div>  <div id="peer" class="p-sm">Beta</div></div>

justify-items has no effect on flex items. Use justify-content to distribute a flex line’s free space.



© 2026 Aoyue Design LLC.MIT License
Trademark Policy