We can use the following two methods to center a text in HTML:
<center></center> tagtext-align:center propertyLet's look at a few examples.
<center></center> tagTo center a text, we can enclose it between the <center></center> tag.
<center>
<p>This text is in center.</p>
</center>
<p> tag. <center></center> tag to wrap the <p> tag and center the text.Note: The
<center></center>tag was deprecated in HTML 4 and is no longer recommended to be used. Some browsers may still support this tag. However, it can stop working at any moment.
text-align:center propertyTo center a text using CSS, we can add the text-align:center property to the element to be centered.
<p>
This text is in center.
</p>
<p> tag and added the text-align:center property to it to center it.