Description & Usage

The justify-content property controls alignment along the main axis of a flex container (or inline axis of a grid container). It manages remaining free space when flex items do not fill the entire container.

Common values like space-between automatically push the first item to the start edge and the last item to the end edge, perfectly distributing remaining space between remaining items. This makes building header navigation bars effortless.

Values like center and space-evenly provide seamless horizontal centering and uniform item padding across modern web component layouts.

Property Specifications

Property FeatureSpecification
CategoryFlexbox
Initial Valueflex-start
InheritedNo (not inherited)
Applies ToFlex and Grid containers
Flexbox Playground
Items:
4
12px
Item 1
Item 2
Item 3
Item 4
.container { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-wrap: nowrap; gap: 12px; }

Syntax

justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly;

Property Values

ValueDescription
flex-startItems are packed toward start line of main axis.
centerItems are centered along main axis.
flex-endItems are packed toward end line of main axis.
space-betweenFirst item at start, last item at end, remaining space evenly distributed between items.
space-aroundItems are evenly distributed with equal space around each item.
space-evenlyItems are distributed so spacing between any two items (and edges) is equal.

Code Examples

Navbar Layout with Logo & Nav Links
.header-nav { display: flex; justify-content: space-between; align-items: center; }
Pushes logo to far left and navigation links to far right.