How to center text in html/css

Using center tags

If you want to center text the most basic way is to use the

<center></center>

and it would go something like this

<center>Center this text</center>

Center this text

But this way is not used anymore it still works but yo should avoid using it

Using a style

The best way to center a little bit of text is doing

<p style="text-align:center;">Center this text</p>

Also Notice how the value of the property “text-align” was set to “center” which indicates that the element is to be centered.

so the text in that will be centered

If you have many sets of text you would like to center, you can use CSS inside <style></style> tags within the head section on the page to declare that every element be centered.

<style>
p { text-align:center; }
</style>

The text will be centered within every set of <p></p> tags on the page.