A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/how-to-center-align-text-in-html/ below:

How to Center Text in HTML?

How to Center Text in HTML?

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 Tag

The <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 &lt;center&gt; tag.</p>
</center>

Output

center tag

Note: The <center> tag is depricated from HTML 5, so we will use CSS text-align property to center the text.

Center Text using text-align Property

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 center

Related 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