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 Grid, as well as the relevant axis.

Justify self class options

The options are classified as:

  • justify-self-auto 
  • justify-self-start 
  • justify-self-end 
  • justify-self-center 
  • justify-self-stretch

justify-self-auto

It is the value that's utilized to align an item based on the grid's justify-items class value.

Syntax:

<element class="justify-self-auto">...</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 Self Class - Tailwind CSS </b> 
    <div id="main" class="grid justify-items-stretch grid-cols-2"> 
        <div class="justify-self-auto bg-red-500 rounded-lg m-4 h-12">
          1
        </div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">2</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">3</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">4</div>
    </div> 
</body> 
  
</html>

Output:

Tailwind CSS Justify Self

justify-self-start

It allows the content to align to the cell's left side.

Syntax:

<element class="justify-self-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 Self Class - Tailwind CSS </b> 
    <div id="main" class="grid justify-items-stretch grid-cols-2"> 
        <div class="justify-self-start bg-red-500 rounded-lg m-4 h-12">
          1
        </div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">2</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">3</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">4</div>
    </div> 
</body> 
  
</html>

Output:

Tailwind CSS Justify Self

justify-self-end

It enables the content to align itself to the cell's right.

Syntax:

<element class="justify-self-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 Self Class - Tailwind CSS </b> 
    <div id="main" class="grid justify-items-stretch grid-cols-2"> 
        <div class="justify-self-end bg-red-500 rounded-lg m-4 h-12">
          1
        </div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">2</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">3</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">4</div>
    </div> 
</body> 
  
</html>

Output:

Tailwind CSS Justify Self

justify-self-center

 It enables the content to align itself with the cell's center.

Syntax:

<element class="justify-self-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 Self Class - Tailwind CSS </b> 
    <div id="main" class="grid justify-items-stretch grid-cols-2"> 
        <div class="justify-self-center bg-red-500 rounded-lg m-4 h-12">
          1
        </div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">2</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">3</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">4</div>
    </div> 
</body> 
  
</html>

Output:

Tailwind CSS Justify Self

justify-self-stretch

This property's default value causes the content to cover the entire width of the cell.

Syntax:

<element class="justify-self-stretch">...</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 Self Class - Tailwind CSS </b> 
    <div id="main" class="grid justify-items-stretch grid-cols-2"> 
        <div class="justify-self-stretch bg-red-500 rounded-lg m-4 h-12">
          1
        </div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">2</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">3</div> 
        <div class="bg-red-500 rounded-lg m-4 h-12">4</div>
    </div> 
</body> 
  
</html>

Output:

Tailwind CSS Justify Self