Tutorialspoint.dev

HTML | center Tag

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

Syntax:

<center> Contents... <center>

Example 1:

<!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>                    

Output:
center tag

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

<!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>                    

Output:
CSS center property

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

  • Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter