CSS justify-items Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Flexbox & Grid

What You’ll Learn

The justify-items property aligns grid items along the inline axis inside each grid cell. It is the grid equivalent of setting horizontal placement for every item at once, without writing rules on each child.

01

Inline Axis

Horizontal in LTR grids.

02

Syntax

Keyword values.

03

Grid Cells

Align inside areas.

04

Default

stretch fills cells.

05

Compare

vs justify-content.

06

Override

Use justify-self.

Introduction

The justify-items property in CSS is used to align grid items along the inline (row) axis within their grid area. It affects how each item is positioned horizontally inside its cell when the item is narrower than the cell.

This property is especially useful in responsive grid layouts where you want icons, cards, or buttons centered or aligned to one side inside equal-width columns.

Definition and Usage

Apply justify-items to a grid container, not to individual items. It sets the default inline-axis alignment for all direct grid items inside their assigned grid areas.

💡
Beginner Tip

For start, center, or end to be visible, grid items usually need a width smaller than their cell. Try width: fit-content or a fixed width on the items.

📝 Syntax

Apply justify-items to a grid container:

syntax.css
.container {
  justify-items: value;
}

Basic Grid Example

justify-items-basic.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: 10px;
}

.grid .item {
  width: fit-content;
}
justify-items: start; justify-items: center; justify-items: end; justify-items: stretch;

Default Value

The default value of justify-items is stretch, which means grid items expand to fill the entire grid area along the inline axis.

Syntax Rules

  • Apply to a grid container, not to individual items (use justify-self for one item).
  • Works along the inline axis inside each grid area.
  • Alignment is visible when items are smaller than their cell.
  • The property is not inherited.
  • Pair with align-items for block-axis alignment inside cells.

⚡ Quick Reference

QuestionAnswer
Initial valuestretch
Applies toGrid containers
InheritedNo
AnimatableNo
Inline axis in LTRHorizontal (left to right)

💎 Property Values

ValueDescription
startAligns items at the start of the grid area’s inline axis.
endAligns items at the end of the grid area’s inline axis.
centerCenters items along the grid area’s inline axis.
stretchStretches items to fill the grid area (default behavior).

justify-items vs justify-content

PropertyWhat it alignsBest for
justify-itemsEach item inside its grid cellCentering cards or icons inside equal columns
justify-contentThe grid tracks as a wholeCentering a narrow grid inside a wide container
align-itemsItems along the block axisVertical alignment inside grid cells

👀 Live Preview

A three-column grid with smaller items using justify-items: center:

1
2
3

Examples Gallery

Center grid cards, align icons to the start, push badges to the end, and compare stretch with centered items.

🚀 CSS Grid Layouts

Use justify-items to control how each grid item sits along the inline axis inside its cell.

Example 1 — Center Items with center

Center compact cards inside equal-width grid columns.

justify-items-center.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: 10px;
}

.item {
  inline-size: 4.5rem;
}
Try It Yourself

How It Works

Each item stays centered inside its own column because the items are narrower than their grid areas.

Example 2 — Start Alignment with start

Align icons or labels to the leading edge of each grid cell.

justify-items-start.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: start;
}
Try It Yourself

How It Works

start pins each item to the inline-start side of its grid area, which is the left side in a normal LTR layout.

Example 3 — End Alignment with end

Push badges or status chips to the trailing edge of each cell.

justify-items-end.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: end;
}
Try It Yourself

How It Works

end moves each item to the inline-end side of its cell, useful for right-aligned badges in dashboard tiles.

Example 4 — Default Stretch Behavior

Let grid items expand to fill the full width of each column.

justify-items-stretch.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: stretch;
}
Try It Yourself

How It Works

stretch is the default. Items grow to match the inline size of their grid area, which is why full-width buttons need no extra alignment rule.

♿ Accessibility

  • Preserve reading order — inline alignment does not change DOM order for assistive technology.
  • Keep touch targets large enough — centered icons still need adequate padding for mobile taps.
  • Support RTL layoutsstart and end follow writing direction, which is safer than hard-coded left/right.
  • Maintain contrast — badges aligned to cell edges must still meet color contrast guidelines.
  • Test zoom and reflow — centered items should remain usable when text size increases.

🧠 How justify-items Works

1

Grid areas are created

The browser divides the container into rows and columns, assigning each item a grid area.

display: grid
2

Item size is resolved

Each item gets its inline size from content, explicit width, or stretch behavior.

Sizing
3

justify-items positions items

When an item is narrower than its cell, the keyword value places it at start, center, or end along the inline axis.

Alignment
=

Consistent cell alignment

One container rule aligns every grid item predictably without per-item margin hacks.

🖥 Browser Compatibility

justify-items is widely supported in modern browsers for CSS Grid layouts.

Baseline · CSS Grid

Reliable grid alignment across browsers

Current Chrome, Firefox, Safari, Edge, and Opera all support justify-items in grid containers.

97% Modern browser support
Google Chrome 57+
Full support
Mozilla Firefox 52+
Full support
Apple Safari 10.1+
Full support
Microsoft Edge 16+
Full support
Opera 44+
Full support
justify-items property 97% supported

Bottom line: Use justify-items confidently in modern CSS Grid layouts.

🎉 Conclusion

The justify-items property gives you precise control over how grid items align along the inline axis inside their cells. Whether you need centered cards, start-aligned icons, or full-width stretched buttons, it offers clear keyword values for the job.

For beginners, start with center on a grid where items use width: fit-content, then compare with stretch to see why the default often looks like no alignment is happening at all.

💡 Best Practices

✅ Do

  • Use center for icon grids and compact card layouts
  • Pair with align-items for full two-axis cell alignment
  • Prefer start and end over physical left/right for RTL support
  • Give items a defined or fit-content width when testing alignment
  • Apply to the grid container for consistent defaults

❌ Don’t

  • Confuse justify-items with justify-content
  • Expect center to work when items already fill the full cell width
  • Apply manual margins on every item when one container rule is enough
  • Forget that justify-self can override the container default
  • Skip testing in RTL or vertical writing modes when alignment matters

Key Takeaways

Knowledge Unlocked

Five things to remember about justify-items

Use these points when building CSS Grid layouts.

5
Core concepts
stretch 02

Default

stretch.

Values
center 03

Center cards

Icon grids.

Pattern
grid 04

Grid focus

Cell alignment.

Scope
content 05

Not justify-content

Items vs tracks.

Compare

❓ Frequently Asked Questions

justify-items sets the default inline-axis alignment for grid items inside their grid areas. It controls how each item sits horizontally within its cell when the item is smaller than the cell.
The initial value is stretch, which makes grid items expand to fill the full width of their grid area along the inline axis.
justify-items aligns individual items inside each grid cell. justify-content aligns the entire grid tracks as a group inside the container when extra inline-axis space remains.
justify-items sets the default alignment for all grid items on the container. justify-self overrides that default for one specific item.
If grid items already stretch to full cell width, centering has no visible effect. Give items a smaller width or use width: fit-content so the browser can position them inside the cell.

Practice in the Live Editor

Open the HTML editor, set display: grid, and try different justify-items values on a three-column layout.

HTML Editor →

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.

5 people found this page helpful