×

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 Width

The tailwind CSS width class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Width Property. This...

3 minutes 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 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 Place Items

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

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

Tailwind CSS can be utilized to make sites in the quickest and the least demanding way. Tailwind CSS is the most famous utility-first CSS structure on the planet for quickly...

4 minutes 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 Max-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 max-width property. This...

3 minutes read.

Tailwind CSS Position

The position class acknowledges more than one value in tailwind CSS. It is an option in contrast to the CSS Position property. This class is utilized for controlling how an...

5 minutes read.

Tailwind CSS Object Position

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

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 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 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 Flex Direction

CSS flexbox is an important element for frontend development. CSS has four directions, therefore in tailwind CSS, all of the properties are covered in class form. It's a front-end development...

5 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 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 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 Stroke

This class accepts a lot of value, and all of the properties are covered in class form. It's the stroke class that goes on top of the SVG element. Stroke...

2 minutes read.