Using HTML to Center Text

If you’re a fan of using HTML then you will want to keep reading to learn how to use HTML to center your text. While the <center> tag is considered deprecated in most layouts, it can still work in most cases. However, CSS style sheets are beginning to take over for normal HTML.

HTML center text

Centering text using HTML

Using HTML to center your text is pretty easy. Simply use the <center></center> tag to enclose the text you would like to center.

For Example:

<center>Hello World!</center>

Using this text within HTML code would provide you with the follow:

Hello World!

Using CSS style sheets to center text

Since HTML is slowly being phased out, you should also know how to center text using CSS. CSS uses the text-align property to understand how to align the text properly.

If you only have a few lines to center then simply adding an attribute is the most simple way to center the text. This will looking similar to something like this:

<p style=”text-align:center”>Hello Centered World!</p>

The text-align property specifically calls out the “center” value in order to center the text. This once again would result in something similar to this:

Hello Centered World!

CSS styling for multiple paragraphs

If you are trying to center several blocks of text,  then you will want to use the <style> tags in the head section or in an external style sheet that is referred to within your page. Setting up a style tag would look something like this:


p {




This code will center all of the text you have enclosed within the <p></p> tags throughout the page.

If you don’t want to center all of your paragraphs then you can create a style class that will allow you to assign that class to any paragraph you want to center.


.center {

 text-align: center



Using this code, whenever you want to center a paragraph within the page you can simply use the class that you established above and wrap your paragraphs with the below code.

<p class="center">Your paragraph here</p>

If you’re looking for a good HTML editor, you can utilize a text editor like Notepad, or if you want a more robust solution you can use something like Notepad++

If your PC has been struggling due to age or hardware issues, Dave’s Computers is here to help. If you are a New Jersey local then swing by their shop at 415 Amwell Road, Suite 103 Hillsborough NJ 08844. Or reach out to them via their website and see how they can assist you.


1 thought on “Using HTML to Center Text”

Leave a Comment