🚀 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 Content

Align items with precision. Learn to control space distribution along the main axis in Flexbox.

style.css
.container {
display: flex;
justify-content: space-between;
}
style.css
1 / 9
🧘

Tutor:In Flexbox, justify-content aligns items along the main axis. By default, items align to the start of the container.


Flexbox Mastery

Unlock nodes by learning alignment properties.

Concept 1: Flex Basics

The justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container. The default value is flex-start.

System Check

Which axis does justify-content affect by default?


Community Holo-Net

Share Layouts

Built a complex nav bar or grid? Share your flex configurations.

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 Content

Author

Pascual Vila

Frontend Instructor.

The justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container.

Alignment Values

This property controls the horizontal alignment (in a row) or vertical alignment (in a column). Common values include:

  • flex-start (default): Items are packed toward the start line.
  • flex-end: Items are packed toward the end line.
  • center: Items are centered along the line.

Spacing Values

You can also use this property to distribute empty space:

  • space-between: Items are evenly distributed; first item is on the start line, last item on the end line.
  • space-around: Items have equal space around them. Note that visually the spaces aren't equal, since the start/end items have one unit of space against the edge, but two units between items.
  • space-evenly: Items are distributed so that the spacing between any two items (and the space to the edges) is equal.

Best Practices

Always remember that justify-content works on the main axis. If you change flex-direction to column, this property will control the vertical alignment, not the horizontal.

Flexbox Glossary

Main Axis
The primary axis along which flex items are laid out. Defined by flex-direction (row or column). justify-content always works on this axis.
Flex Container
The parent element that has display: flex or inline-flex set. Direct children become flex items.
flex-start
The default value. Items align to the left in a LTR row, or top in a column.
space-between
Distributes items evenly. The first item is flush with the start, the last item is flush with the end.