The text-align property in CSS is used for aligning the inner content of a block element.
CSS Syntax
text-align: left | right | center | justify | initial | inherit;
Let's see an example:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
div{
text-align:right;
}
p{
text-align:center;
}
</style>
</head>
<body>
<div> Example for the text-align property. </div>
<p>Some paragraph for example.</p>
</body>
</html>
Property Values
Value | Descriptions |
---|---|
left | The default value. It aligns the text to the left. |
right | It aligns the text to the right. |
center | It aligns the text to the center. |
justify | Extends the lines so that each line has equal width. |
initial | It makes the property use its default value. |
inherit | It inherits the property from its parents element. |