Open In App

Tailwind CSS Text Alignment

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

This class accepts lots of values in tailwind CSS in which all the properties are covered in class form. It is the alternative to the CSS text-align property. This class is used to specify the horizontal alignment of text in an element.

Text Alignment classes:

  • text-left
  • text-center
  • text-right
  • text-justify

text-left: It is used to set the text-alignment to the left.

Syntax:

<element class="text-left">...</element>

Example:

HTML




<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
 
<body class="text-center mx-4 space-y-2">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>
    <b>Tailwind CSS Text Alignment Class</b>
    <div class="mx-24 bg-green-200">
        <p class="p-4 text-left">
            Geeksforgeeks: A Computer Science portal for Geeks
            those who wants to pursue an engiinering degree or
            wants to create a career on engineering field.
        </p>
 
 
    </div>
</body>
 
</html>


Output:

text-center: It is used to set the text-alignment into the center.

Syntax:

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

Example:

HTML




<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
 
<body class="text-center mx-4 space-y-2">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>
    <b>Tailwind CSS Text Alignment Class</b>
    <div class="mx-24 bg-green-200">
        <p class="p-4 text-center">
            Geeksforgeeks: A Computer Science portal for Geeks
            those who wants to pursue an engiinering degree or
            wants to create a career on engineering field.
        </p>
 
 
    </div>
</body>
 
</html>


Output:

text-right: It is used to set the text-alignment into right.

Syntax:

<element class="text-right">...</element>

Example:

HTML




<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
 
<body class="text-center mx-4 space-y-2">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>
    <b>Tailwind CSS Text Alignment Class</b>
    <div class="mx-24 bg-green-200">
        <p class="p-4 text-right">
            Geeksforgeeks: A Computer Science portal for Geeks
            those who wants to pursue an engiinering degree or
            wants to create a career on engineering field.
        </p>
 
 
    </div>
</body>
 
</html>


Output:

text-justify: It is used to stretch the content of an element to display the same width of each line.

Syntax:

<element class="text-left">...</element>

Example:

HTML




<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
 
<body class="text-center mx-4 space-y-2">
    <h2 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h2>
    <b>Tailwind CSS Text Alignment Class</b>
    <div class="mx-24 bg-green-200">
        <p class="p-4 text-justify">
            Geeksforgeeks: A Computer Science portal for Geeks
            those who wants to pursue an engineering degree or
            wants to create a career on engineering field.
        </p>
 
 
    </div>
</body>
 
</html>


Output:

text justify



Last Updated : 07 Oct, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads