CSS Text

Most of the web-page content is text and therefore text styling is an important aspect.

CSS styles the text with the following properties:

  • color
  • text-align
  • text-decoration
  • text-shadow
  • text-transform
  • direction
  • letter-spacing
  • word-spacing
  • line-height
  • text-indent

color

The text color can be set using the color property using the following three permissible values:
Color-name
RGB Code
Hex

Run

text-align

The horizontal alignment of the text can be done using this property. We can align the text to the left, right or center.

Apart from that, the text-align property can also be set to ‘justify’ wherein, every line will be stretched to maintain an equal width for all lines.
Different values for text align properties are
left | right| center | justify | initial |inherit

Run

Run

Run

text-decoration

This is basically to add or remove decorations from the text. For no decoraction the value is set to ‘none’.

Some other values for decoration are ‘overline’, ‘line-throught’, ‘underline’.

Possible values for test-decoration properties are
none |underline|line-through|overline|inherit

Run

text-transform

This property has to do with the cases of the letters in the text.

You can transform the text to lowercase, uppercase or capitalize (make the first letter of every word as capital)

different values for text-transform property are
capitalize | uppercase | lowercase | none | inherit

Run

Run

text-indent

Text indent is the empty space from stating point in first line. The text indentation can be altered by providing appropriate length value to this property.
values for text-indent are
percentage | length | inherit

Run

letter-spacing

The space between individual characters can be defined with this property.

A positive will mean a well-defined space while a negative value will mean overlapping of characters.

values for letter spacing
normal | length| inherit

Run

line-height

The individual vertical distance between two lines can be set with this property.

values for line height are
normal | number | length | percentage

Run

Direction

The text direction is also an important factor in styling. Basically, your text will proceed in left to right (ltr) or right to left (rtl).

The default value is ltr. Also, in case of ltr, the default text aligment is left and vice-versa.
values for text directions are

ltr | rtl | inherit

Run

word-spacing

This is for the horizontal spacing among the words. Just like letter-spacing property, the value here too can be positive or negative.

values for word-spacing property is
normal |length | inherit

Run

text-shadow

It gives a shadow effect to the text.

The value is given as
horizontal-shadow | vertical-shadow | blur-radious | shadow color

Run