HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. Justify Content

CSS Flexbox

Justify Content

The justify-content property is used to control the horizontal alignment and spacing of flex items along the main axis of a flex container.

It determines how extra space is distributed between and around flex items. The supporting concepts are explained in Flex Direction and Align Items.

The justify-content property works only on a flex container and is one of the most commonly used Flexbox properties.

Syntax

Justify Content Syntax

css

.container {
    display: flex;
    justify-content: value;
}

Justify Content Example

css

.container {
    display: flex;
    justify-content: center;
}

This centers all flex items horizontally within the container.

Attributes

ValueDescriptionExample
flex-startAligns items at the beginningjustify-content: flex-start;
centerCenters items horizontallyjustify-content: center;
flex-endAligns items at the endjustify-content: flex-end;
space-betweenEqual space between itemsjustify-content: space-between;
space-aroundEqual space around itemsjustify-content: space-around;
space-evenlyEqual spacing everywherejustify-content: space-evenly;

Example

Justify Content Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>Justify Content Example</title>
    <style>
        .container {
            display: flex;
            justify-content: space-between;
            border: 2px solid black;
            padding: 10px;
        }
        .item {
            background-color: lightblue;
            padding: 20px;
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item">Item 1</div>
        <div class="item">Item 2</div>
        <div class="item">Item 3</div>
    </div>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
justify-content in Flexbox5212207

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

  • justify-content works along the main axis.
  • For flex-direction: row, it controls horizontal alignment.
  • For flex-direction: column, it controls vertical alignment.
  • It only affects flex items inside a flex container.
  • Often used together with align-items.

Visual Comparison

flex-start

text

Item1 Item2 Item3

center

text

      Item1 Item2 Item3

flex-end

text

                Item1 Item2 Item3

space-between

text

Item1      Item2      Item3

space-around

text

  Item1    Item2    Item3

space-evenly

text

   Item1   Item2   Item3

Conclusion

The justify-content property provides precise control over how flex items are distributed within a flex container. It helps create balanced, responsive, and visually appealing layouts by managing spacing and alignment along the main axis.

PreviousFlex DirectionNextAlign Items