CSS Text Alignment and Text Direction.
The following properties are about CSS text alignment and text direction.
text-aligntext-align-lastdirectionunicode-bidivertical-align
CSS Text Alignment.
The CSS text-align property is used to set the horizontal alignment of a text.
Text alignment can be done in four ways.
leftrightcenterjustify
When the text-align property is set to "Justify", each line is stretched so that each line has the same width.
Example
#p1 {
text-align: center;
}
#p2 {
text-align: left;
}
#p3 {
text-align: right;
}
#p4 {
text-align: justify;
}
Click on the "Try it Now" button to see how it works.
CSS Text Align Last.
The text-align-last property specifies how to align the last line of text.
Example
#p1 {
text-align-last: right;
}
#p2 {
text-align-last: center;
}
#p3 {
text-align-last: justify;
}
Click on the "Try it Now" button to see how it works.
CSS Text Direction
The direction and unicode-bidi attributes can be used to change the direction of an element's text.
Click on the "Try it Now" button to see how it works.
CSS Vertical Alignment
The vertical-align property specifies the vertical alignment of an element.
Example
#p1 {
vertical-align: baseline;
}
#p2 {
vertical-align: text-top;
}
#p3 {
vertical-align: text-bottom;
}
#p4 {
vertical-align: sub;
}
#p5 {
vertical-align: super;
}
Click on the "Try it Now" button to see how it works.