CSS text-align property

The CSS text-align property is used to specify the horizontal alignment of the inner content of an element. The default value for text-align is left.

CSS text-align property

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

ValueDescription
leftAligns the content to the left side
rightAligns the content to the right side
centerAlignts the content to center
justifyThe 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


Share Tweet Send
Loading...
You've successfully subscribed to Geekinsta
Great! Next, complete checkout for full access to Geekinsta
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.