CSS text-align Horizontally Property
The text-align property specifies the horizontal alignment of text in an element. By default, the text on your website is aligned to the left. However, at times you may require a different alignment.
text-align property values are as follows: left, right, center, and justify.
HTML
1 2 3 |
<p class="left">Welcome to PHPGurukul <strong>left.</strong></p> <p class="right">Welcome to PHPGurukul <strong>right.</strong></p> <p class="center">Welcome to PHPGurukul <strong>center.</strong></p> |
CSS
1 2 3 4 5 6 7 8 9 10 11 |
<style type="text/css"> p.left { text-align: left; } p.right { text-align: right; } p.center { text-align: center; } </style> |
Output
When text-align is set to “justify“, each line is stretched so that every line has equal width, and the left and right margins are straight (as in magazines and newspapers).