×

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 Grid Auto Columns

The Grid Auto Columns class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS grid-auto-columns property. The size of the...

5 minutes read.

Tailwind CSS 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 height property. This class is used...

4 minutes read.

Tailwind CSS Place Content

This class accepts a wide range of values. It's a replacement for the CSS Place Content property. This class is used to manage how information is justified while still being...

5 minutes read.

Tailwind CSS Grid Auto Flow

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It is a CSS alternative. The grid-auto-flow property is used in Tailwind...

4 minutes read.

Tailwind CSS Align Items

In tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Items attribute. This class is used to align things within the flexible...

5 minutes read.

Tailwind CSS Object Fit

It acknowledges more than one value in tailwind CSS. Every one of its properties is covered as in class form. It is the option in contrast to the CSS object-fit...

4 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 Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 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 Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

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 Space Between

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 Space Between property....

4 minutes read.

Tailwind CSS Align Content

In Tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Content feature. This class is used to modify the flex-wrap property's behavior....

5 minutes read.

Tailwind CSS Visibility

In tailwind CSS, this class accepts two values. It's a replacement for the CSS visibility property. This class specifies whether an element in a web document is visible or not,...

2 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 Stroke Width

In tailwind CSS, this class takes a large number of values and all of the properties are covered in the form. It is used to specify the width of an...

1 minute read.

Tailwind CSS Opacity

This class accepts a lot of value, and all of the properties are covered in class form. We can change the opacity of any element by using this class. The...

1 minute 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 Grid Auto Rows

In tailwind CSS, this class takes multiple values and covers all of the properties in class form. It's a replacement for the grid-auto-rows CSS attribute. The size of the rows...

6 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.