How to align any text to center | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to align any text to center

How to align any text to center

25th Apr 2020, 9:11 AM
Najib Shaikh
Najib Shaikh - avatar
3 Answers
+ 9
You can do this by using center tag,using inline style and using css . It can be done using any of them it depends upon you.
25th Apr 2020, 11:18 AM
Rimjhim
Rimjhim - avatar
+ 1
<center> put your text here </center>
25th Apr 2020, 9:23 AM
Prabhat Ranjan
Prabhat Ranjan - avatar
0
<center> element is deprecated/obsolete in html5... you must use a block container and apply to it the css rule "text-align:center;" for horizontal centering... of the container width (be aware that block elements got the max width available if their container as default behaviour, and you must turn it to css rule "display:inline-block" to be able to constrain it to custom width...) For vertical centering it will be a few more tricky, but modern browsers provide useful ways to do so (until you need to support older browsers, with wich you must rely on oldest technics harder to implement (needs more workaround to reach the goal, but not impossible)
25th Apr 2020, 7:58 PM
visph
visph - avatar