Traditionally in <center>
tag to align text in a centered horizontal manner. This <center>
element is no longer supported in HTML5, as it got deprecated in HTML4.
Now the text-align
property provides multiple features to align text or blocks of text such as:
margin-right
margin-left
auto
We can apply these attributes individually on blocks like <div>
, <p>
, etc.
<center> content will be here.... </center>
text-align
For the latest browsers, we can use CSS to align text in different ways such as: center
, right
, and left
.
We can use CSS in different ways, as shown below.
style
attribute on <p>
<p>
This line will be centered.<br> am I centered aligned?
</p>
style
attribute on <div>
<div> This text will be centered.
<p> hello, I am centered aligned. </p>
</div>
This code snippet shows how to use the <center>
element in your HTML code. This prints the <p>
(paragraph) tag as centered text using CSS to increase the font-size
and its color
.