Skip to content
Related Articles

Related Articles

HTML <center> Tag
  • Difficulty Level : Basic
  • Last Updated : 09 Feb, 2021

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

Syntax: 

<center> Contents... </center>

Example 1: This example illustrates the HTML center tag. 

HTML




<!DOCTYPE html>
<html>
  <body>
    <!--center tag starts here -->
    <center>
      <h1>GeeksforGeeks</h1>
      <h2><center> tag</h2>
        
<p>GeeksforGeeks: A computer science portal for geeks</p>
  
      <!--center tag ends here -->
    </center>
  </body>
</html>

Output: 
 



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

HTML




<!DOCTYPE html>
<html>
  <body>
    <h1>GeeksforGeeks</h1>
    <!--center using CSS style  -->
    <h2 style="text-align: center">CSS center property</h2>
  </body>
</html>

Output: 

Supported Browsers: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :