×

Tailwind CSS Justify Content

In tailwind CSS, this class accepts two values. It's a replacement for CSS's justify-content attribute. This class is used to describe the flexible box container's alignment. Along the main axis of a flex container, it contains the space between and surrounding content components. It is used to regulate how flex and grid objects are positioned along the main axis of a container.

Justify Content classes

The classes are listed as follows:

  • justify-start
  • justify-end 
  • justify-center 
  • justify-between 
  • justify-around 
  • justify-evenly 

justify-start

 It is used to align flex components from the beginning of the container.

Syntax:

<element class="justify-start">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-start flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

justify-end

This property is used to align flex components from the container's end.

Syntax:

<element class="justify-end">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-end flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

justify-center

 The justify-center property is used to align flex components from the container's center.

Syntax:

<element class="justify-center">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-center flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

justify-between

 The flex elements are spaced evenly, with the first item pushed to the left and the last item pushed to the right.

Syntax:

<element class="justify-between">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-between flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

justify-around

The corners are where the flex elements are placed, with equal spacing between them.

Syntax:

<element class="justify-around">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-around flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

justify-evenly

The objects are spaced evenly between them, although the spacing from the corners varies.

Syntax:

<element class="justify-evenly">...</element>

Example:

<!DOCTYPE html> 
<head> 
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"> 
</head> 
  
<body class="text-center"> 
    <h1 class="text-red-600 text-5xl font-bold">
        Javatpoint
    </h1> 
    <b>Justify Content Class - Tailwind CSS </b> 
    <div id="main" class="flex justify-evenly flex-row"> 
        <div class="bg-red-700 w-24 h-12">1</div> 
        <div class="bg-red-600 w-24 h-12">2</div> 
        <div class="bg-red-500 w-24 h-12">3</div> 
        <div class="bg-red-400 w-24 h-12">4</div> 
    </div> 
</body> 
</html>

Output:

Tailwind CSS Justify Content

Related Topics

Tailwind CSS Container

In Tailwind CSS, a compartment is utilized to fix the maximum width (max-width) of a component to match the min-width of the breakpoint. It comes exceptionally convenient when content must...

2 minutes read.

Tailwind CSS Justify Self

The class form goes over the various properties. It's a replacement for the CSS justify-self attribute. This class is used to describe the alignment of content’s position in a CSS...

4 minutes read.

Tailwind CSS Max-Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Max-Height attribute. It is used to...

3 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Grid Row Start / End

In tailwind CSS, this class takes several values. All of the attributes are covered in the form of a class. In CSS, it's an alternative to the grid-row attribute. It's...

4 minutes read.

Tailwind CSS Grid Template Rows

In tailwind CSS, this class accepts multiple values and all properties are covered in class form. It's the CSS grid-template-row property's replacement. It is used to set the number of...

2 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Grid Template Columns

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's the CSS grid-template-columns property's replacement. It's used to specify the number...

2 minutes read.

Tailwind CSS Align Self

This class accepts a wide range of values. It's a replacement for the CSS Align Self attribute. This class is used to control how a flex or grid item is...

4 minutes read.

Tailwind CSS Display

It acknowledges more than one worth in tailwind CSS. Every one of the properties is shrouded as in class structure. It is an option in contrast to the CSS display...

5 minutes read.

Tailwind CSS Fill

The CSS Fill class accepts a lot of value, and all of the properties are covered in class form. It is a presentation attribute that controls how an SVG shape's...

1 minute read.

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.

Tailwind CSS Box Sizing

Tailwind CSS Box sizing class acknowledges more than one worth in tailwind CSS. Each property is shrouded as a class structure. It is an option in contrast to the CSS...

2 minutes read.

Tailwind CSS Installation

Here, we will discuss the installation method of Tailwind CSS using two strategies discussed as follows: Strategy 1: Install Tailwind through npm Step 1: npm init - y Step 2: npm install tailwindcss Step...

2 minutes read.

Tailwind CSS Padding

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Padding Property. This class is used...

4 minutes read.

Tailwind CSS Box Shadow

The Tailwind CSS Box Shadow class accepts a lot of value, and all of the properties are covered in class form. We may control the box-shadow of an element by...

2 minutes read.

Tailwind CSS Float

The float class acknowledges more than one worth (value) in tailwind CSS. It is an option in contrast to the CSS float property. The float class characterizes the progression of...

4 minutes read.

Tailwind CSS Min-Height

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Min-Height Property. It...

2 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.