Blog

Text Alignment in CSS: Tips, Tricks, and Best Practices

Written by Pawan Sharma | Sep 20, 2024 1:30:00 PM

The text-align property in CSS is used to set the horizontal alignment of text within an element. It works for block-level elements such as <p>, <div>, <h1>, etc. Here are the common values for text-align:

  1. left: Aligns the text to the left. This is the default setting.
  2. right: Aligns the text to the right.
  3. center: Centers the text horizontally within its container.
  4. justify: Stretches the text so that each line has equal width, aligning both left and right edges.


HTML Example: