Justify-content
The CSS justify-content property distributes flex items or grid tracks along the relevant container axis when free space is available.
Web Design Playground, Second Edition
The CSS justify-content property controls how flex or grid items are distributed along their container's main axis.
- How it is used
- Arranges flex items along a container’s main axis, from simple centering to spacing items in page layouts.
- How deep it goes
- Defines six values, compares their visible effects, and works through centering; does not descend into layout internals.
- Examples
- Uses a centered heading, a photo-gallery header, and portfolio images spread with space-between.
- What you can do after
- Apply it via CSS to center flex items or distribute them across a container.
Read how Web Design Playground, Second Edition explains justify-content →
Tiny CSS Projects
The CSS justify-content property controls how free space is distributed along the main axis of a flex or grid layout.
- How it is used
- Positions flex children by distributing leftover space, from centering a profile card to separating credit-card details.
- How deep it goes
- Explains four values through layout rules and shows why unequal item widths can make a space-around row look off-center.
- Examples
- Shows a centered profile card and actions, spaced profile statistics, and details arranged across a virtual credit card.
- What you can do after
- Apply it via CSS Flexbox to center children or distribute them across a container, while checking gaps and unequal widths.
Web Design Playground
A CSS alignment property that distributes and aligns items along the main axis of a flex container or grid container.
- How it is used
- Arranges flex items along the container’s main axis, including centering page content or aligning a nested column at its start.
- How deep it goes
- Defines five values and explains their placement, default, and `space-around` gap behavior; does not develop layout internals.
- Examples
- Uses an interactive value playground, a window-centered heading, and nested flex containers in a portfolio layout.
- What you can do after
- Operate/configure it by choosing a CSS value that positions flex items along the main axis.
CSS in Depth, Second Edition
The CSS justify-content property distributes grid tracks or flex items along the container's inline or main axis when free space is available.
- How it is used
- Positions flex items or grid tracks along the relevant horizontal or main axis when free space remains.
- How deep it goes
- Explains core values, logical-direction behavior, spacing differences, and calculation order, while deferring exhaustive examples.
- Examples
- Demonstrates a centered stylized price using flex items and positions grid tracks within an oversized grid container.
- What you can do after
- Apply justify-content to center, edge-align, or distribute flex items and grid tracks according to available space.
Read how CSS in Depth, Second Edition explains justify-content →
Also covered in
- Vanilla WebIn early access (MEAP)
What to know first
- body elementThe HTML body element contains the content of a document intended for display in a browser.
- viewportA viewport is the visible region of a browser or graphical interface in which a document or other content is displayed.
- display propertyThe CSS property that specifies how an element generates boxes and participates in layout.
- flexboxFlexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
Related concepts
- main axisuses · The main axis is the primary direction in which a flex container arranges and distributes its flex items.
- flexboxconfigures · Flexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
- flex containerconfigures · A flex container is an element whose children are laid out as flex items according to the CSS Flexible Box Layout model.
- place-contentequivalent to · The CSS place-content shorthand property sets how content is aligned and distributed along a container’s axes.
- grid containerconfigures · A grid container is an element whose display mode establishes a CSS Grid formatting context for laying out its child elements as grid items.
Questions about justify-content
What is justify-content?
The CSS justify-content property distributes flex items or grid tracks along the relevant container axis when free space is available.
Which Manning books explain justify-content?
Web Design Playground, Second Edition, Tiny CSS Projects, Web Design Playground and CSS in Depth, Second Edition.
What should I know before learning justify-content?
Manning books that teach justify-content usually introduce body element, viewport, display property and flexbox first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



