How to Align Text in HTML? Last Updated : 23 May, 2025 Comments Improve Suggest changes Like Article Like Report In earlier versions of HTML, the align attribute was commonly used to align text to the left, right, or center. However, this attribute is now deprecated in HTML5 and should no longer be used in modern web development. Instead, text alignment is handled more effectively using CSS with the text-align property, which offers greater flexibility and cleaner code. According to modern web standards, over 95% of professional websites now rely on CSS for styling, including text alignment, making it the preferred approach for consistent and responsive design.Method 1. Align Text using the "align attribute" [deprecated]The align attribute is used to specify the text alignment within paragraph tags and set the text position to left, center, or right. index.html <p align="left"> This text is left-aligned using the align attribute. </p> <p align="center"> This text is center-aligned using the align attribute. </p> <p align="right"> This text is right-aligned using the align attribute. </p> Outputalign text using align attributeMethod 2. Align text using "CSS text-align Property" [Recommended]The text-align property is used to set the horizontal alignment of text within an element. It applies to block-level elements and aligns the inline content accordingly. index.html <!DOCTYPE html> <html> <head> <style> .left-align { text-align: left; } .center-align { text-align: center; } .right-align { text-align: right; } </style> </head> <body> <p class="left-align"> This text is left-aligned using the text-align property. </p> <p class="center-align"> This text is center-aligned using the text-align property. </p> <p class="right-align"> This text is right-aligned using the text-align property. </p> </body> </html> Outputtext align property How to Align Text in HTML? Comment More infoAdvertise with us Next Article How to align Image in HTML? Y ysachin2314 Follow Improve Article Tags : Web Technologies HTML Class 7 HTML-Questions Similar Reads How to Center Text in HTML? 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 elemen 1 min read How to align Placeholder Text in HTML ? The placeholder attribute specifies a short hint that describes the expected value of an input field/text area. The short hint is displayed in the field before the user enters a value. In most of the browsers, placeholder texts are usually aligned on the left. The selector uses the text-align proper 2 min read How to align Image in HTML? Aligning images within a webpage is an essential part of web design. It allows you to control how images are positioned about surrounding content. In HTML, there are several ways to align images using both attributes and CSS techniques, ranging from simple alignment to more advanced responsive layou 4 min read How to align Image in HTML? Aligning images within a webpage is an essential part of web design. It allows you to control how images are positioned about surrounding content. In HTML, there are several ways to align images using both attributes and CSS techniques, ranging from simple alignment to more advanced responsive layou 4 min read How to align Image in HTML? Aligning images within a webpage is an essential part of web design. It allows you to control how images are positioned about surrounding content. In HTML, there are several ways to align images using both attributes and CSS techniques, ranging from simple alignment to more advanced responsive layou 4 min read How to Wrap Text in HTML? To wrap text in HTML, you can use the default behaviour of block-level elements like <p>, <div>, and <h1>, which automatically wrap text to fit within their parent container. For more control over text wrapping, you can use CSS properties like word-wrap, white-space, and overflow-w 3 min read Like