The CSS text-align property is used to specify the horizontal alignment of the inner content of an element.
Syntax
text-align: left|right|center|justify;
Values
Value | Description |
left | Aligns the content to the left side |
right | Aligns the content to the right side |
center | |
justify | The contents are justified |
Example
<!DOCTYPE html>
<html>
<head>
<title>CSS text align</title>
<style>
.ms-center{
text-align: center;
}
.ms-justify{
text-align: justify;
}
.ms-right{
text-align: right;
}
</style>
</head>
<body>
<h2 class="ms-center">CSS text-align</h2>
<p class="ms-justify">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Cupiditate impedit quisquam voluptatum iusto ullam vero laudantium dicta perferendis ut ratione! Nemo, veritatis culpa. Repudiandae at sequi ad asperiores harum soluta.</p>
<p class="ms-right">Mishel Shaji</p>
</body>
</html>
Output
CSS text-align
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Cupiditate impedit quisquam voluptatum iusto ullam vero laudantium dicta perferendis ut ratione! Nemo, veritatis culpa. Repudiandae at sequi ad asperiores harum soluta.
Mishel Shaji