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.
Fundamentals
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.
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.
A11y
♿ 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 layouts — start 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.
Compatibility
🖥 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 Chrome57+
Full support
Mozilla Firefox52+
Full support
Apple Safari10.1+
Full support
Microsoft Edge16+
Full support
Opera44+
Full support
justify-items property97% supported
Bottom line: Use justify-items confidently in modern CSS Grid layouts.
Wrap Up
🎉 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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about justify-items
Use these points when building CSS Grid layouts.
5
Core concepts
↔01
Inline Axis
Inside each cell.
Purpose
stretch02
Default
stretch.
Values
center03
Center cards
Icon grids.
Pattern
grid04
Grid focus
Cell alignment.
Scope
content05
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.