4 Ways to Bring Your Text At the Center Using HTML

Spread the love

What would the reason that your text is not showing at the center? Either applied according to the HTML elements.

There are four ways to bring the text in the center using HTML:

How to Center text in HTML?

<center> element

First of all you can Use the <center></center> tags:

<center>This is heading</center>

The second way:

Using style sheet

You can be used the style sheet property:

You can center text with CSS by specifying the text-align property of the element.

If you have only one or a few blocks of text to center, add the <style> </style> attribute to the element’s opening tag and use the “text-align” property.


text-align: center;


Centering a few blocks of text

If you have many blocks of text to center, use CSS inside <style></style> tags in the head section or in an external style sheet. See the example code below for how to set all text inside the <span></span> tags to be centered.

<span style="text-align: center;">This text is in center </span>

Text of multiple blocks:

If you’re creating a center class, as showing was in the example above, a paragraph can be centered using the code below, which “calls” the center class.

<p class="center">This text is in center</p>

Keep reading: How to Add HTML Space Between Buttons?

Leave a Comment