HTML | center Tag

The <center> tag in HTML is used to set the align of text into the center. This tag is not supported in HTML5. CSS property is used to set the align of the element instead of the center tag in HTML5.

Syntax:

<center> Contents... <center>

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>center tag</title>
        <style>
            h1 {
                color:green;
            }
        </style>
    </head>
    <body>
        <center>
            <h1>GeeksforGeeks</h1>
            <h2><center> Tag</h2>
            <p>GeeksforGeeks: 
             A computer science portal for geeks</p>
        </center>
    </body>
</html>                    

chevron_right


Output:
center tag

Example 2: Use CSS property in HTML5 to set the text alignment into center.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>CSS center property</title>
        <style>
            body {
                text-align:center;
            }
            h1 {
                color:green;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>CSS center property</h2>
    </body>
</html>                    

chevron_right


Output:
CSS center property

Supported Browser: The browser supported by <center> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.