🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › justify-content
justify-content - CSS - MDN Web Docs
The CSS justify-content property defines how the browser distributes space between and around content items along the main axis of a flex container and the inline axis of grid and multicol containers.
🌐
W3Schools
w3schools.com › cssref › css3_pr_justify-content.php
CSS justify-content property
The justify-content property aligns the flexible container's items when the items do not use all available space on the main-axis (horizontally).
Discussions

html - Controlling the amount of space in justify-content: space-between - Stack Overflow
I was wondering how to justify how much space is allowed in justify-content: space-between for flexbox. Currently, my items are spaced but they have way too much space between them I want just a l... More on stackoverflow.com
🌐 stackoverflow.com
why is my justify-content: space-between not working on flex items?
The flex value of space-evenly doesn't affect the width of flex content, it only relate to white space. So by default all elements start in a flexbox with a width of auto (ie. their default width assuming nothing is declared) then flex shrinks them to fit if they would overflow. Space-evenly simly means once everything is there, any unused space is shared evenly between each item. In your case you have a div to house the image, divs are block elements (meaning they default to 100% of their parent width). The other elements have their width defined by content, so everything else takes up a width it needs as determined by length of content. Then the div tries to be 100% but flex shrinks it to fit, therefore it takes all remaining space... a close to 100% as will fit. This leaves no white space for space evenly to affect. So in short, even though you are using flexbox you still need a width on the image div, or a flex value on it. More on reddit.com
🌐 r/csshelp
3
1
January 20, 2024
What is difference between justify-self, justify-items and justify-content in CSS grid? - Stack Overflow
I'm really confused. When looking for online resources and documentation, most of the documentation of these properties seem to reference Flex-box, not grid. And I don't know how applicable the More on stackoverflow.com
🌐 stackoverflow.com
In flexbox, whats the difference between setting justify-content to flex-start and start ?
ELI5 answer The flex-start/end keywords are part of the Flexible Box Layout Module Level 1 specification. The start/end keywords are part of the Box Alignment Module Level 3 specification. The Box Alignment 3 spec simplified the grammar, allowing for an easier and less annoying use of properties and keywords. Example: The gap property that used to be grid-gap, worked only with grid, obviously. Later they decided that they want the gap property for the flexbox as well, and instead adding the prefix like flex-gap, they simplified the things and went with gap, which is the shorthand for row-gap and column-gap Edit: like u/iwiik said, these keywords are not well supported yet for flexbox. More on reddit.com
🌐 r/css
8
21
August 13, 2020
🌐
Tailwind CSS
tailwindcss.com › docs › justify-content
justify-content - Flexbox & Grid - Tailwind CSS
Use the justify-between utility to justify items along the container's main axis such that there is an equal amount of space between each item:
🌐
CSS Reference
cssreference.io › property › justify-content
justify-content - CSS Reference
justify-content: space-between; The remaining space is distributed between the flexbox/grid items. 1. One · 2. Two · 3. Three · justify-content: space-around; The remaining space is distributed around the flexbox/grid items: this adds space ...
🌐
Quackit
quackit.com › css › css3 › properties › css_justify-content.cfm
CSS justify-content
The justify-content property aligns flex items along the main axis of the current line of the flex container. It defines how space is distributed between and around flex items.
🌐
CSS-Tricks
css-tricks.com › almanac › properties › j › justify-content
justify-content | CSS-Tricks
September 22, 2022 - The ‘space-between’ and ‘space-around’ properties would probably accurately show this in action but ‘flex-start’ and ‘flex-end’ properties have absolutely nothing to do with ‘justifying’. It really bugs me when clients ask for copy to be ‘left justified’ when they actually mean ‘left aligned’. ... I am pretty sure that as of today (August 4th, 2017), justify-content: space-evenly is not yet available.
🌐
MDN
mdn2.netlify.app › en-us › docs › web › css › justify-content
justify-content - CSS: Cascading Style Sheets | MDN
February 18, 2022 - The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container.
🌐
GeeksforGeeks
geeksforgeeks.org › css › css-justify-content-property
CSS justify-content Property - GeeksforGeeks
July 11, 2025 - The justify-content property in CSS is used to align the flexible box container's items along the main axis of a flex container. This property manages space distribution between and around content items in a flex container.
Find elsewhere
🌐
SheCodes
shecodes.io › athena › 98677-what-is-justify-content-in-css
[CSS] - What is justify-content in CSS? - SheCodes Athena - | SheCodes
Learn about the CSS property justify-content and how it is used to align and distribute flex items in a flex container.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › CSS_flexible_box_layout › Aligning_items_in_a_flex_container
Aligning items in a flex container - CSS - MDN Web Docs
justify-content: Controls the alignment of all items on the main axis. align-items: Controls the alignment of all items on the cross axis. align-self: Controls the alignment of an individual flex item on the cross axis. align-content: Controls the space between flex lines on the cross axis.
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › utilities › flex
Flex · Bootstrap
Use justify-content utilities on flexbox containers to change the alignment of flex items on the main axis (the x-axis to start, y-axis if flex-direction: column). Choose from start (browser default), end, center, between, or around.
🌐
W3cubDocs
docs.w3cub.com › css › justify-content
Justify-content - CSS - W3cubDocs
The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container. The interactive example below demonstrates some of the values using Grid Layout.
🌐
Reddit
reddit.com › r/csshelp › why is my justify-content: space-between not working on flex items?
r/csshelp on Reddit: why is my justify-content: space-between not working on flex items?
January 20, 2024 -

>> https://codepen.io/coderr11/pen/rNRwVmy

My code pen is above.

header is the parent, where i have placed: display: flex, align-items: center, and justify-content: space-evenly on it.

The child elements of it are .logo-image, .navbar, .btn and .fas - However, .logo-image takes up most of the width as seen by the red background and other flex items are squished to the left and are spaced-evenly. I can define a width on the .logo-image, but why is the default nature of it takes so much space compared to the other flex items?

Thank you

Top answer
1 of 5
150

To answer your questions:

1

As reiallenramos mentioned, "The justify-self and justify-items properties are not implemented in flexbox. This is due to the one-dimensional nature of flexbox, and that there may be multiple items along the axis, making it impossible to justify a single item. To align items along the main, inline axis in flexbox you use the justify-content property." - MDN

2-3

This screen shot from W3 does an excellent job of showing what they do and the differences between them.

Good To Knows:

For more information and example, I would suggest you check out:

  • https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout
  • https://www.smashingmagazine.com/2017/06/building-production-ready-css-grid-layout/
  • https://www.smashingmagazine.com/2017/12/grid-inspector/

And for some inspiration:

  • https://www.smashingmagazine.com/2017/10/css-grid-challenge-2017-winners/
2 of 5
124

Key differences between justify-content, justify-items and justify-self in CSS Grid:

  • The justify-content property controls the alignment of grid columns. It is set on the grid container. It does not apply to or control the alignment of grid items.
  • The justify-items property controls the alignment of grid items. It is set on the grid container.
  • The justify-self property overrides justify-items on individual items. It is set on grid items and inherits the value of justify-items, by default.

Example

Here's a 2x3 grid.

  • 2 columns, each 100px wide
  • 3 rows, each 50px tall

The container is:

  • 500px wide
  • 250px tall

.container {
    display: grid;
    grid-template-columns: 100px 100px;
    grid-template-rows: 50px 50px 50px;
    width: 500px;
    height: 250px;
    grid-template-areas: " one two"
                         " three four"
                         " five six ";
}

.box:nth-child(1) {  grid-area: one;   }
.box:nth-child(2) {  grid-area: two;   }
.box:nth-child(3) {  grid-area: three; }
.box:nth-child(4) {  grid-area: four;  }
.box:nth-child(5) {  grid-area: five;  }
.box:nth-child(6) {  grid-area: six;   }

/* non-essential decorative styles */
body {
    display: flex;
    justify-content: center;
}
.container {
    background-color: #ddd;
    border: 1px solid #aaa;
}
.box {
    background-color: lightgreen;
    border: 1px solid gray;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
}
<div class="container">
    <div class="box"><span>1</span></div>
    <div class="box"><span>2</span></div>
    <div class="box"><span>3</span></div>
    <div class="box"><span>4</span></div>
    <div class="box"><span>5</span></div>
    <div class="box"><span>6</span></div>    
</div>


justify-content

The justify-content property aligns columns within the container.

.container {
  justify-content: space-between;
}

.container {
    display: grid;
    grid-template-columns: 100px 100px;
    grid-template-rows: 50px 50px 50px;
    width: 500px;
    height: 250px;
    grid-template-areas: " one two"
                         " three four"
                         " five six ";
}

.box:nth-child(1) {  grid-area: one;   }
.box:nth-child(2) {  grid-area: two;   }
.box:nth-child(3) {  grid-area: three; }
.box:nth-child(4) {  grid-area: four;  }
.box:nth-child(5) {  grid-area: five;  }
.box:nth-child(6) {  grid-area: six;   }

/* non-essential decorative styles */
body {
    display: flex;
    justify-content: center;
}
.container {
    background-color: #ddd;
    border: 1px solid #aaa;
}
.box {
    background-color: lightgreen;
    border: 1px solid gray;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
}
<div class="container">
    <div class="box"><span>1</span></div>
    <div class="box"><span>2</span></div>
    <div class="box"><span>3</span></div>
    <div class="box"><span>4</span></div>
    <div class="box"><span>5</span></div>
    <div class="box"><span>6</span></div>    
</div>

With justify-content: space-between both columns are pinned to the edges. The grid items shift only because they exist inside those columns. They are otherwise unaffected.

Note that this property works only when there is free space in the container. If any of the columns were sized with fr, then all free space would be consumed, and justify-content would have no effect.


justify-items

The justify-items property aligns grid items within their tracks (not the entire container)

.container {
  justify-items: center;
}

.container {
    display: grid;
    grid-template-columns: 100px 100px;
    grid-template-rows: 50px 50px 50px;
    width: 500px;
    height: 250px;
    grid-template-areas: " one two"
                         " three four"
                         " five six ";
}

.box:nth-child(1) {  grid-area: one;   }
.box:nth-child(2) {  grid-area: two;   }
.box:nth-child(3) {  grid-area: three; }
.box:nth-child(4) {  grid-area: four;  }
.box:nth-child(5) {  grid-area: five;  }
.box:nth-child(6) {  grid-area: six;   }

/* non-essential decorative styles */
body {
    display: flex;
    justify-content: center;
}
.container {
    background-color: #ddd;
    border: 1px solid #aaa;
}
.box {
    background-color: lightgreen;
    border: 1px solid gray;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
}
<div class="container">
    <div class="box"><span>1</span></div>
    <div class="box"><span>2</span></div>
    <div class="box"><span>3</span></div>
    <div class="box"><span>4</span></div>
    <div class="box"><span>5</span></div>
    <div class="box"><span>6</span></div>    
</div>

With justify-items: center the grid items are centered within their columns.


justify-self

The justify-self property overrides justify-items on individual items.

.container        { justify-items: center;}
.box:nth-child(2) { justify-self: start; }
.box:nth-child(3) { justify-self: end; }
.box:nth-child(6) { justify-self: stretch; }


.container {
    display: grid;
    grid-template-columns: 100px 100px;
    grid-template-rows: 50px 50px 50px;
    width: 500px;
    height: 250px;
    grid-template-areas: " one two"
                         " three four"
                         " five six ";
}

.box:nth-child(1) {  grid-area: one;   }
.box:nth-child(2) {  grid-area: two;   }
.box:nth-child(3) {  grid-area: three; }
.box:nth-child(4) {  grid-area: four;  }
.box:nth-child(5) {  grid-area: five;  }
.box:nth-child(6) {  grid-area: six;   }

/* non-essential decorative styles */
body {
    display: flex;
    justify-content: center;
}
.container {
    background-color: #ddd;
    border: 1px solid #aaa;
}
.box {
    background-color: lightgreen;
    border: 1px solid gray;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
}
<div class="container">
    <div class="box"><span>1</span></div>
    <div class="box"><span>2</span></div>
    <div class="box"><span>3</span></div>
    <div class="box"><span>4</span></div>
    <div class="box"><span>5</span></div>
    <div class="box"><span>6</span></div>    
</div>


align-content, align-items and align-self

These properties do the same as their justify-* counterparts, but in the perpendicular direction.

More here: What is the difference between align-items vs. align-content in Grid Layout?


Spec Reference

10.3. Row-axis Alignment: the justify-self and justify-items properties

Grid items can be aligned in the inline dimension by using the justify-self property on the grid item or justify-items property on the grid container.

10.4. Column-axis Alignment: the align-self and align-items properties

Grid items can also be aligned in the block dimension (perpendicular to the inline dimension) by using the align-self property on the grid item or align-items property on the grid container.

10.5. Aligning the Grid: the justify-content and align-content properties

If the grid’s outer edges do not correspond to the grid container’s content edges (for example, if no columns are flex-sized), the grid tracks are aligned within the content box according to the justify-content and align-content properties on the grid container.

(emphasis added)


CSS Box Alignment Module

You wrote:

Is the justify-items property in Flex-box the same as the justify-items property in Grid?

Although the Flex and Grid specs provide their own definitions for keyword alignment properties, such as justify-items and align-content, the W3C is in the process of phasing out alignment properties for individual box models and implementing their new Box Alignment Module, which seeks to define a set of alignment properties for use across all box models.

From the flexbox spec:

1.2. Module interactions

The CSS Box Alignment Module extends and supercedes the definitions of the alignment properties (justify-content, align-items, align-self, align-content) introduced here.

There are similar references in the Grid spec.

🌐
PureCode AI
blogs.purecode.ai › home › justify content css: empowering you to make beautiful layouts
Justify Content CSS: Empowering You to Make Beautiful Layouts - Blogs
September 15, 2025 - It adds consistent space between each adjacent pair of items, effectively pushing the items to the outer edges of the container while maintaining equal spacing between them. In essence, justify-content is a Flexbox property that governs the horizontal alignment and spacing of flex container items along the main axis...
🌐
Bootstrap Shuffle
bootstrapshuffle.com › classes › flexbox › justify-content-*-between
justify-content-*-between - Bootstrap CSS class
<div class="d-flex justify-content-between"> <div class="p-2">Flex item 1</div> <div class="p-2">Flex item 2</div> <div class="p-2">Flex item 3</div> </div> <!-- responsive variations --> <div class="d-flex justify-content-sm-between">...</div> <div class="d-flex justify-content-md-between">...</div> <div class="d-flex justify-content-lg-between">...</div> <div class="d-flex justify-content-xl-between">...</div>Copy code
🌐
PrimeFlex
primeflex.org › justifycontent
Justify Content - PrimeFlex
PrimeFlex Justify Content defines the alignment on the main axis.
🌐
Web Reference
webreference.com › css › properties › justify-content
justify-content | WebReference
The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container.