CSS justify-items Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The justify-items property sets the default justify-self for items in a box. In grid, it aligns each item along the inline axis inside its grid area (left–right in a horizontal writing mode).

Put it on the container, not on each item. It is ignored in flexbox and table cells. To move the whole set of tracks inside a wider container, use justify-content. To override one item, use justify-self.

Standard-track.

Not deprecated. Grid keywords are widely available (Baseline since 2016). anchor-center is newer and still limited; prefer stretch, center, start, and end for study and production basics.

CSS Syntax

syntax.css
justify-items: normal | stretch | center | start | end | initial | inherit;

Also valid: left, right, self-start, self-end, baseline, optional safe / unsafe, and legacy forms.

Property Values

ValueDescriptionTry it
normalIn grid, usually acts like stretch (except some intrinsic / aspect-ratio boxes)Try it
stretchAuto-sized items grow to fill the cell on the inline axisTry it
centerPack each item toward the center of its cellTry it
startPack each item toward the start edge of its cellTry it
endPack each item toward the end edge of its cellTry it
initialResets to the initial value legacyTry it
inheritTakes the parent’s justify-items (not inherited by default)Try it

How to Use justify-items

Build a grid with cells larger than the item content, then choose how items sit inside those cells.

  1. Set display: grid on the container.
  2. Give tracks enough size so cells are wider than the content (for example 1fr 1fr).
  3. Leave item width as auto so stretch can grow them, or let content size them for center / start / end.
  4. Set justify-items on the container. Override one cell with justify-self if needed.
PieceRequired?Role
Grid containerYes (for this lesson)Where justify-items is set
Cells larger than contentYes (to see position keywords)Without spare cell width, center looks like stretch
KeywordYesstretch, center, start, end, and related values

Live Preview

A 2×2 grid. Change justify-items and watch how each label sits inside its cell.

Gray areas inside each cell are unused cell space on the inline axis.

Grid
One
Two
Three
Four

justify-items: center

CSS Examples

Each snippet keeps only what justify-items needs: a grid and cells wider than the labels. Use Try It Yourself for a live editor.

Example 1 — Center in Each Cell

Size items to their content and place them in the middle of each grid area.

CSS
<style>
  section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-items: center;
    border: 1px solid #ccc;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
  <div>Four</div>
</section>
Try It Yourself

How It Works

  1. Make a grid. Two equal columns create four cells that are wider than the short labels.
  2. Leave width auto. Items shrink to their content instead of filling the cell.
  3. Center each item. justify-items: center places every item in the middle of its cell on the inline axis.
  4. One rule for all. The container sets the default; you do not need justify-self on each child.

Example 2 — Start Edge

Pack every item against the start edge of its cell.

CSS
<style>
  section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-items: start;
    border: 1px solid #ccc;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
  <div>Four</div>
</section>
Try It Yourself

How It Works

  1. Same grid. Two columns still leave spare width inside each cell.
  2. Start packing. justify-items: start aligns each item to the inline-start edge (left in LTR).
  3. Spare space stays. Unused space sits on the end side of each cell.
  4. Swap for end. end does the opposite—items hug the inline-end edge.

Example 3 — Stretch Across the Cell

Grow auto-sized items so they fill the full inline size of each grid area.

CSS
<style>
  section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-items: stretch;
    border: 1px solid #ccc;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
  <div>Four</div>
</section>
Try It Yourself

How It Works

  1. Auto width. Items with an automatic inline size can grow.
  2. Fill the cell. justify-items: stretch expands each item across its grid area.
  3. Fixed width blocks it. A set width on an item prevents stretch; use center or start for those cases.
  4. Usual grid look. This is the familiar “full-width card in a cell” default many layouts rely on.

Edge Cases & Pitfalls

If nothing moves, the item may already fill the cell—or you may be in flex layout.

flex

Ignored in flexbox

justify-items has no effect on flex containers. Use justify-content or align-items instead.

width

Full-width items hide position keywords

If every item already spans the cell (stretch or a width: 100%), center and start look identical. Shrink the content box first.

vs

Not justify-content

justify-content moves tracks inside the container. justify-items moves items inside cells. You often set both on the same grid for different jobs.

self

justify-self wins for one item

The container default comes from justify-items. A single child can override it with justify-self.

place

Shorthand: place-items

place-items sets align-items and justify-items together when both axes should share a keyword.

Browser Support

justify-items is a browser layout property (mainly CSS Grid). Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since 2016

justify-items

Chrome 57+, Firefox 45+, Safari 10.1+, Edge 16+. Internet Explorer has no grid justify-items support.

96% modern browsers
Google Chrome 57+
Full support
Mozilla Firefox 45+
Full support
Apple Safari 10.1+
Full support
Microsoft Edge 16+
Full support
Opera 44+
Full support
Samsung Internet 6.2+
Full support
Internet Explorer No support
None
justify-items Widely supported

Bottom line: Safe for modern grid layouts. Stick to stretch, center, start, and end for the widest, simplest study path. Newer keywords like anchor-center need extra care.

Key Takeaways

  • Role: default inline-axis alignment of items inside their areas (set on the container).
  • Best with grid: ignored in flexbox; teach it on display: grid.
  • Not justify-content: cells vs tracks—different jobs on the same grid.
  • Override: use justify-self on one item when the default should not apply.

One line: justify-items is the container default for how each grid item sits left–right inside its cell.

Frequently Asked Questions

It sets the default justify-self for items in a container. In grid, that means how each item aligns along the inline axis inside its grid area.
The initial value is legacy. In grid, the usual visible default is stretch-like sizing across the cell unless you set another keyword.
justify-items aligns each item inside its cell. justify-content distributes free space around the grid tracks when the grid is narrower than the container.
justify-items is set on the container and applies to all items. justify-self overrides that default on one item.
No. In flex layout the property is ignored. Use justify-content or align-items on the flex container instead.
Grid support is widely available: Chrome 57+, Firefox 45+, Safari 10.1+, and Edge 16+. It is a browser layout property, not a Node.js feature.

Next: justify-self

Override the container default for a single grid item.

justify-self tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful