CSS | text-align Property
The text-align property in CSS is used to specify the horizontal alignment of text in an element.
Syntax:
text-align: left|right|center|justify|initial|inherit;
Property Value: The text-align property value are listed below:
- left: It is used to set the text-alignment into left.
- right: It is used to set the text-alignment into right.
- center: It is used to set the text-alignment into center.
- justify: It is used to stretched the content of an element to display the same width of each line.
- initial: It is used to set its default value.
- inherit: It is inherited from its parent.
Example:
<!DOCTYPE html> <html> <head> <title>text-align property</title> <style> h1 { color:green; } h1, h2, h3 { text-align:center; } .main { border:1px solid black; } .gfg1 { text-align:left; } .gfg2 { text-align:right; } .gfg3 { text-align:center; } .gfg4 { text-align:justify; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>text-align property</h2> <div class = "main"> <h3>text-align: left;</h3> <div class = "gfg1"> The course is designed for students as well as working professionals to prepare for coding interviews. This course is going to have coding questions from school level to the level needed for product based companies like Amazom, Microsoft, Adobe, etc. </div> </div><br> <div class = "main"> <h3>text-align: right;</h3> <div class = "gfg2"> The course is designed for students as well as working professionals to prepare for coding interviews. This course is going to have coding questions from school level to the level needed for product based companies like Amazom, Microsoft, Adobe, etc. </div> </div><br> <div class = "main"> <h3>text-align: center;</h3> <div class = "gfg3"> The course is designed for students as well as working professionals to prepare for coding interviews. This course is going to have coding questions from school level to the level needed for product based companies like Amazom, Microsoft, Adobe, etc. </div> </div><br> <div class = "main"> <h3>text-align: justify;</h3> <div class = "gfg4"> The course is designed for students as well as working professionals to prepare for coding interviews. This course is going to have coding questions from school level to the level needed for product based companies like Amazom, Microsoft, Adobe, etc. </div> </div> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by text-align property are listed below:
- Google Chrome 1.0
- Internet Explorer 3.0
- Firefox 1.0
- Opera 3.5
- Safari 1.0
Recommended Posts:
- HTML | DOM Style textAlign Property
- HTML | canvas textAlign Property
- p5.js | textAlign() Function
- CSS | transition-property Property
- CSS | nav-up property
- CSS | top Property
- CSS | nav-right property
- CSS | nav-down property
- CSS | right Property
- CSS | all Property
- Web API | DOMRectReadOnly x property
- CSS | clear Property
- CSS | grid-gap Property
- CSS border Property
- CSS | clip Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



