Tailwind CSS Text Alignment
Last Updated :
23 Jul, 2025
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>
<html>
<head>
<link href="https://unpkg.com/[email protected]/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>
<html>
<head>
<link href="https://unpkg.com/[email protected]/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>
<html>
<head>
<link href=
"https://unpkg.com/[email protected]/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>
<html>
<head>
<link href="https://unpkg.com/[email protected]/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