CSS Text Alignment

The text-align property in CSS is used to specify the horizontal alignment of text in an element.

The following are some of the most common values for the text-align property:

To use the text-align property, you need to add it to the style declaration of the element that you want to align. For example, to align the text in a div element to the right, you would use the following code:

Try yourself
        
            div {
    text-align: right;
}
        
    

You can also use the text-align property to align the text in an image. To do this, you need to add the text-align property to the style declaration of the image's parent element. For example, to align the text in an image that is inside a div element to the right, you would use the following code:

Try yourself
        
            div {
    text-align: right;
}