Which CSS property sets the horizontal alignment of text?
Answer
text-align
Answer
text-align
The CSS property that sets the horizontal alignment of text is text-align.
It controls how inline content is aligned within a block or table-cell box. Common values include left, right, center, and justify, with the exact default behavior also influenced by the document’s writing direction. For example, text-align: center centers text across the available inline width.
text-align is a CSS presentation property, so it keeps alignment separate from HTML structure. This separation was one of CSS’s original purposes: the CSS1 specification included alignment of text, images, and tables among its capabilities. The property is inherited, which means a child element generally receives its parent’s alignment unless another rule overrides it.
A frequent mix-up is vertical-align. Despite the similar name, vertical-align handles vertical positioning of inline-level content or table-cell content, not the left-to-right arrangement of paragraph lines. text-justify is related to justification details, but it does not replace text-align, which chooses the overall alignment mode.
Source: Wikipedia · fact-checked Aug. 2026