🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS justify-items

Control alignment along the inline axis. Learn how to center, start, and end items within a grid.

style.css
.container {
display: grid;
justify-items: center;
}
/* Result: Items centered horizontally */
1
2
grid.css
1 / 8
🧊

Tutor:The justify-items property aligns grid items along the inline (row) axis. It defaults to 'stretch'.


Grid Mastery Tree

Unlock nodes by learning grid alignment properties.

Concept 1: Grid Context

justify-items is a property applied to a Grid Container (an element with display: grid). It controls the default alignment of all children within their respective grid cells.

System Check

Where do you apply justify-items?


Community Holo-Net

Share Layouts

Created a complex grid system? Share your alignment patterns.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS justify-items Property

Author

Pascual Vila

Frontend Instructor.

The justify-items property aligns grid items along the inline (row) axis. It applies to grid containers and defines the default justify-self for all child items.

Common Values

  • stretch (Default): Items fill the width of the cell.
  • start: Items align to the start edge (left in LTR).
  • end: Items align to the end edge (right in LTR).
  • center: Items align to the center.

Justify-Items vs Align-Items

justify-items controls alignment on the horizontal (inline) axis.

align-items controls alignment on the vertical (block) axis.

Best Practices

Use justify-items on the parent container to set a global alignment for all children. If you need a specific child to differ, use justify-self on that specific item.

Justify Items Glossary

Inline Axis
The axis running horizontally (in standard layouts), corresponding to the direction of text flow. justify-items controls this.
justify-items: center
Centers the item horizontally within its grid cell.
justify-items: stretch
The default value. Items stretch to fill the entire width of the cell.
justify-self
A property used on individual grid items to override the justify-items value set on the container.