CSS text-align Property
Description
The text-align property controls the horizontal alignment of inline content inside a block container. It affects where text runs and inline-level boxes (like inline-block and replaced inline elements such as images) are placed within the container’s content area, shaping the flow and visual rhythm of lines. Because it targets inline content, it does not move block-level boxes themselves; block-level children remain laid out according to the block formatting context unless other layout properties intervene.
In practical terms, text-align is often set on a parent block so all descendant inline content inherits that alignment, making it a convenient way to establish consistent line alignment across headings, paragraphs, and inline elements. Some layout contexts treat it specially: table cells, for example, use this property to align cell contents, and nested block containers will inherit the computed value so that inner text continues the same alignment unless explicitly overridden. When content contains multiple inline boxes or forced line breaks, the property determines how each line's inline content is positioned within the available inline progression dimension.
This property interacts with several other text and layout controls. For language-direction and mirrored layouts you will often use direction to influence which side is considered the start or end of a line. Handling the final line of a paragraph (which can behave differently from intermediate lines) can be refined with text-align-last, while full-line justification behavior is influenced by text-justify. How and whether lines wrap at all affects alignment outcomes, so white-space plays a role, and visual density or spacing between baselines (which changes how aligned lines look relative to one another) is affected by line-height.
When applying text-align in real layouts, remember it’s primarily a typographic tool rather than a general-purpose layout mechanism. It’s ideal for controlling line composition and the alignment of inline content inside boxes, but aligning entire boxes or grid/flex items is handled by other layout properties. Use text-align to establish readable, consistent text flow, and combine it deliberately with the related text properties above when you need finer control over wrapping, justification, and behavior in different writing directions.
Definition
- Initial value
- start
- Applies to
- Block containers
- Inherited
- Yes
- Computed value
- As specified, except for the match-parent value which is calculated against its parent's direction value and results in a computed value of either left or right
- Animatable
- No
- JavaScript syntax
- object.style.textAlign
Interactive Demo
Syntax
text-align: start | end | left | right | center | justify | match-parent | start end
Values
- startInline-level content is aligned to the start edge of the line box.
- endInline-level content is aligned to the end edge of the line box.
- leftInline-level content is aligned to the left edge of the line box.
- rightInline-level content is aligned to the right edge of the line box.
- justifyThe text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.
- centerInline-level content is centered within the line box.
- match-parentSimilar to inherit with the difference that the value start and end are calculated according the parents direction and are replaced by the adequate left or right value.
- start endSpecifies start alignment of the first line and any line immediately after a forced line break; and end alignment of any remaining lines.
- inherit
Example
Browser Support
The following information will show you the current browser support for the CSS text-align property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
