justify-content
Defines how the browser distributes space between and around content items along the main axis of a flex container or the inline axis of a grid container.
Quick example
.container {
display: flex;
justify-content: space-between;
} /* pushes items to the edges with even space between */ Syntax
justify-content: <alignment-keyword>flex-startflex-endcenterspace-betweenspace-aroundspace-evenlystretchQuick facts
normalExamples
Push items to the edges
.header {
display: flex;
justify-content: space-between;
} Common pattern for navigation bars: logo on the left, menu on the right, gap automatically fills the middle.
Center a row of items
.toolbar {
display: flex;
justify-content: center;
gap: 1rem;
} Centers a group of items horizontally. Use gap to control spacing between them.
Equal spacing around items
.tabs {
display: flex;
justify-content: space-evenly;
} space-evenly gives equal space before, between, and after items. Different from space-around, where outer gaps are half the size of inner gaps.
justify-content Browser Support
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.
Safe to use without fallbacks.
Common pitfalls
justify-content has no effect on a plain block container. You must set display: flex or display: grid on the parent first.
justify-content aligns on the main axis. When flex-direction is row (default), that is horizontal. When flex-direction is column, the main axis is vertical. align-items controls the cross axis.
With a single flex item, space-between pushes it to the start (there is no gap to distribute). If you want a single item centered, use justify-content: center or margin: auto.
See also
align-itemsjustify-itemsplace-contentgap