CSS — Text Align
Published in
Jul 27, 2022
To align the text to different positions on the page we use the “text-align” property. It’s just like the float property.
text-align: right;
But it actually aligns it according to its parent element. That means if I put it in a div and make it smaller than the page then it will be aligned to the right of that div and not the page itself.
<div>
<p>This is some text.</p>
</div>div {
width: 500px;
background-color: red;
}
p {
text-align: right;
}
You can also align the text in different positions like:
text-align:left;
text-align:center;
Justified text stretches the letter adjusting the space between them and fills up the whole element.
div {
width: 500px;
background-color: yellow;
}
p {
text-align: justify;
}
Instructor ~ TARUN KUMAR