This chapter will cover the following properties:
The text-align property is employed to determine the horizontal alignment of text.
Text can be aligned to the left, right, centered, or justified.
Below is an example illustrating center-aligned text, as well as left and right-aligned text. (Left alignment is default when the text direction is left-to-right, and right alignment is default when the text direction is right-to-left):
Example
h1 { |
If the text-align property is specified as “justify”, each line is expanded to ensure uniform width, resulting in straight left and right margins, akin to magazines and newspapers.
Example
div { |
p.a { |
p { direction: rtl; unicode-bidi: bidi-override; } |
The vertical-align property determines the vertical positioning of an element.
Example
Adjust the vertical alignment of an image within a block of text.
img.a { |
Property |
Description |
direction |
Specifies the direction of text or writing. |
text-align |
Specifies the horizontal positioning of text. |
text-align-last |
Specifies the alignment of the last line of text. |
unicode-bidi |
When combined with the direction property, it sets or retrieves whether the text should be overridden to accommodate multiple languages within the same document. |
vertical-align |
Specifies the vertical positioning of an element. |