CSS — Text Align

CSS — Text Align
CSS — Text Align

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;
Text Aligned to The Right
Text Aligned To The 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;
}
Text Aligned Right in A Div
Text Aligned Right in A Div

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;
}
Justified Text
Justified Text

Instructor ~ TARUN KUMAR

LAZY SYNTAX

--

--