Flexbox & Grid

place-items

Set the default block-axis and inline-axis alignment inside grid areas.

Overview

ClassDeclarations
place-items:normalplace-items: normal;
place-items:baselineplace-items: baseline;
place-items:centerplace-items: center;
place-items:stretchplace-items: stretch;
place-items:startplace-items: start;
place-items:endplace-items: end;
place-items:flex-startplace-items: flex-start;
place-items:flex-endplace-items: flex-end;
place-items:self-startplace-items: self-start;
place-items:self-endplace-items: self-end;
place-items:<align-items>|<justify-items>place-items: <align-items> <justify-items>;

Examples

Align grid items on both axes

place-items:center sets both align-items:center and justify-items:center. Each label centers within its own column and 160px row. The grid tracks keep their full size; only the items move inside their areas.

Align grid items on both axes
Each item aligns within its own grid area. Stretch applies only to dimensions that remain automatic.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px place-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  }  .place-items\:center {    place-items: center  }}

For different values, put block-axis alignment first and inline-axis alignment second, such as place-items:start|center.

Stretch automatic-sized items

place-items:stretch fills both dimensions of a grid area when the corresponding item sizes are automatic. The blue item has no width or height, so it fills its area. The violet item keeps its explicitly set 80 × 64px size.

Stretch automatic-sized items
Each item aligns within its own grid area. Stretch applies only to dimensions that remain automatic.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px place-items:stretch gap-md w:17.5rem max-w:100%">  <div id="target" class="p-sm">Auto size</div>  <div id="peer" class="h:4rem w:5rem p-sm">80 × 64</div></div>

Minimum and maximum sizes still apply. Use place-self when just one child needs an override.

Apply conditionally

Use conditional queries to change alignment at a real viewport width. Both automatic-sized labels fill their areas initially, then take intrinsic sizes and center in those same areas from sm.

Apply conditionally
place-items: Apply conditionally controls
Each item aligns within its own grid area. Stretch applies only to dimensions that remain automatic.
<div id="layout" class="grid grid-cols:2 grid-template-rows:160px place-items:stretch gap-md w:17.5rem max-w:100% place-items:center@sm">  <div id="target" class="p-sm">Alpha</div>  <div id="peer" class="p-sm">Beta</div></div>

For flex items, only the align-items half affects alignment. justify-items does not distribute a flex line’s free space; use justify-content for that.



© 2026 Aoyue Design LLC.MIT License
Trademark Policy