It only works because we set a width for this paragraph though.
This paragraph needs to be really long in order to show how to justify text. This just shows the four possible types of text-alignment. Start end Specifies start alignment of the first line and any line immediately after a forced line break and end alignment of any remaining lines not affected by text-align-last. Match-parent Similar to inherit with the difference that the value start and end are calculated according the parent’s direction and are replaced by the adequate left or right value. Text should line up their left and right edges to the left and right content edges of the paragraph. This allows to align numeric values on the decimal point, for instance. the keyword that follows or precedes it indicates how it is aligned. The first occurrence of the one-char string is the element used for alignment. Right The inline contents are aligned to the right edge of the line box.Ĭenter The inline contents are centered within the line box.
Left The inline contents are aligned to the left edge of the line box. Values start The same as left if direction is left-to-right and right if direction is right-to-left.Įnd The same as right if direction is left-to-right and left if direction is right-to-left. Applies to block containersĬomputed 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ĬSS Object Model Property textAlign Syntax Overview table Initial value start, or a nameless value that acts as left if direction is ltr, right if direction is rtl, if start is not supported by the browser. text-align does not control the alignment of block elements itself, only their inline content. The text-align CSS property describes how inline content like text is aligned in its parent block element.