Open In App
Related Articles

Differences between HTML <center> Tag and CSS “text-align: center;” Property

Improve Article
Save Article
Like Article

If you are designing a simple web page, then not much difference is noticeable, but it is very necessary to understand the basic differences between these two. Since we are only concerned with the text, these elements do not have separate meanings.
HTML <center> tag: The <center> tag in HTML is used to set to align of text into the center. This tag is not supported in HTML 5. CSS property is used to set the alignment of the element instead of the center tag in HTML 5. It is a block-level element that is used to display the text enclosed in the tag in the center horizontally. Most common browsers such as Google Chrome, Mozilla Firefox, Internet Explorer support this tag.

  • Example: The below code was earlier used in HTML 4 and older versions to align text to the center.


    <!DOCTYPE html>
            h1 {
                color: green;
            <h2>HTML center Tag</h2>
                GeeksforGeeks: A computer science portal for Geeks.

  • Output:

CSS “text-align: center;” Property: It is a CSS property used to align the text in the center, which can be used in many components, including tables, buttons, etc.

  • Example: The implementation of “text-align: center” property is given below:


    <!DOCTYPE html> 
            text-align: center property
            h1 { 
        <h1 style="text-align:center;">
        <h2 style="text-align:center;">
            CSS "text-align:center;" Property
        <p style="text-align:center;">
            A computer science portal for Geeks.

  • Output:

You can notice both the outputs are the same, but in the case of HTML5 code, we use inline CSS to align our text to the center. In the previous code for HTML4 and older versions, we use specifically the <center> tag.
Differences between HTML <center> tag and CSS “text-align: center;” property: 

HTML <center> tagCSS “text-align: center;” Property
HTML <center> tag is a block level element.CSS “text-align: center;” property is an inline element.
It is best to attach it to a section of a web page.It is best to attach it to a small section of a line in a web page.
HTML 5 does not support the center tag, and also the upcoming versions of HTML would not support it.HTML 5 supports the “text-align: center;” property, and also the upcoming versions of HTML will support it.
This tag should use to wrap a section, for centering that section.This tag should use to wrap any specific word that you want to center on your webpage.

Last Updated : 18 May, 2021
Like Article
Save Article
Similar Reads
Related Tutorials