avatar

Hassan khan

Last updated: December 22,2022

Center text in html

Center text in a div


There is no built-in tag in HTML 5 that centers the text in HTML, but we can achieve this with CSS. There are many methods in CSS to center text in HTML. We will use the 'text-align' property of CSS.


This property can be applied to the 'div' tag, 'p' tag, etc. With the help of this method, you will learn how to center text in a div.


Center text in a div example:

1
2
3
<div style="text-align:center">
  This text will be centered.
</div>

Share