Last Updated : 23 Jul, 2025
To center text in HTML, we can use CSS text-align: center property. It aligns the text to center horizontally. The <center> tag was used in older versions to center the text horizontally, but it is depreciated in HTML 5.
Center Text using center TagThe <center> tag is a block-level element that is used to center text horizontally within its container element.
HTML
<center>
<h1>GeeksforGeeks</h1>
<p>This text is centered using the <center> tag.</p>
</center>
Output
center tagCenter Text using text-align PropertyNote: The <center> tag is depricated from HTML 5, so we will use CSS text-align property to center the text.
The text-align property is the simplest way to horizontally center the text. It is suitable for both inline and block-level elements like paragraphs (<p>), headings (<h1> to <h6>), and divs (<div>).
HTML
<div style="text-align: center;">
<h1>GeeksforGeeks</h1>
<p>This text is centered using text-align.</p>
</div>
Output
text-align centerRelated Article: How to center text in CSS ?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4