How To Set Text-Alignment in CSS | Use of CSS With HTML

How To Set Text-Alignment in CSS

Like us on facebook to get more updates.

 




  • The text-align property is used to set the horizontal of a text.
  • Text can be centered, or aligned to the left, or right, or justified.

Syntax:

h1{

text-align:center;

}





Property Values:

Value Description
left Align the text to the left
right Align the text to the right
center Align the text to the center
justify Stretches the lines (each line has equal width)
Initial Set to property to its default value
Inherit Inherits this property from its parent element





Example:

<html>

    <head>

        <style type="text/css">

            h1{

                text-align:right;

            }

            p{

                text-align:center;

            }

        </style>

        <title>Text Alignment</title>

    </head>

    <body>

        <h1>

            This is a heading.

        </h1>

        <p>

            This is a paragraph.

        </p>

    </body>

</html>





Output:

text-alignmentIf you want to learn Java programming language then you should download this app Click Here




Leave a Reply

Your email address will not be published. Required fields are marked *