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 =
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 =
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 =
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 =
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
07 Oct, 2022
Like Article
Save Article