CSS Text
There are many ways to display text on a web page with the help of CSS. We will discuss them in this section.Align text
There can be four types of alignments, namely, left, right, center and justified. Hence, there can be only four possible values of the property, text-align. Example:Output: This text in center alignedThis text is left aligned
This text is right alignedThis is justified text. We have seen the other types of alignments.
This text in center alignedThis text is left aligned
This text is right alignedThis is justified text. We have seen the other types of alignments.
Decorate Text
By using text-decoration property, the text can be decorated. Following are the ways of decorating the text.Example:
The above values of text-decoration are self-explanatory.This text has line over it
This text has line through middleThis is underlined text
This is blinking text
Output:
So, the output is what we desired but if you are using Internet Explorer, the last style, text-decoration: blink will not work. This command does not work in Internet Explorer.This text has line over it
This text has line through middleThis is underlined text
This is blinking text
Indent Text
The text can be indented by using the text-indent property. The value of this property can be specified either in units or as a percentage.Example:
Output: This is some text in a division. We have indented text and the value is specified in pixel units. Let's see how the text will look.This text is in a paragraph The text is indented and the value is specified as a percentage. Let's see the outcome
This is some text in a division. We have indented text and the value is specified in pixel units. Let's see how the text will look.This text is in a paragraph The text is indented and the value is specified as a percentage. Let's see the outcome
Change Case of Text
By using the text-transform property, you can change the case of your text.Example:
Output: This text is in uppercaseThis text is in lowercase
This text is in capitalcaseThis text will remain unchanged
This text is in uppercaseThis text is in lowercase
This text is in capitalcaseThis text will remain unchanged
Set Direction of Text
The direction of the text can be set by using the property, direction.Example:
Output:This text is from right to left.This text is from left to right. This is default.
This text is from right to left.This text is from left to right. This is default.
