HTML <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: In this example, we simply used the “Hi Geeks” content in the HTML center tag.
HTML
<!DOCTYPE html>
< html >
< body >
< h2 >Welcome to GeeksforGeeks</ h2 >
< center >Hi Geeks</ center >
</ body >
</ html >
|
Output:

HTML <center> tag
Example 2: In this example, the HTML code employs the <center>
tag to center-align content within the web page.
HTML
<!DOCTYPE html>
< html >
< body >
< center >
< h1 >GeeksforGeeks</ h1 >
< h2 >html center tag</ h2 >
< p >GeeksforGeeks: A computer science portal for geeks</ p >
</ center >
</ body >
</ html >
|
Output:

Example 3: In this example, CSS styling is used to center-align content.Â
HTML
<!DOCTYPE html>
< html >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 style = "text-align: center" >
CSS center property
</ h2 >
</ body >
</ html >
|
Output:

HTML <center> tag
Supported Browsers:
- Google Chrome
- Microsoft Edge 12 and above
- Internet Explorer
- Firefox
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
05 Dec, 2023
Like Article
Save Article