typography

text-align

Sets the horizontal alignment of inline content inside a block. start and end respect the writing direction, which is preferred for internationalized sites.

text-align: start | end | left | right | center | justify | match-parent

Common values

Value Effect
start Aligns to the start edge in current writing direction
center Centers inline content horizontally
end Aligns to the end edge in current writing direction
justify Stretches lines to both edges
left Physical left alignment regardless of language
right Physical right alignment regardless of language

Examples

.hero { text-align: center; }

Centered hero copy

article p { text-align: start; }

Left-aligned in LTR, right-aligned in RTL

.prose { text-align: justify; hyphens: auto; }

Justified paragraphs with automatic hyphenation

Gotcha

text-align does not center block-level children; use margin: auto or a flex container for that.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox