CSS Basics Web development basics

CSS Text

CSS text formatting defines various properties to apply style to text.

CSS Text Color

The color property is used to set the color of the text.

With CSS, a color is most often specified by:

  • a color name – like “red”
  • a HEX value – like “#ff0000”
  • an RGB value – like “rgb(255,0,0)”

Try it yourself:

I am red colored text
I am #333399 colored text

Text alignment

text-align property is used to set horizontal alignment of the text. Values supported are: left, right,justify, center.

Text decoration

text-decoration property is used to decorate text.
text-decoration:none; is used to remove underlines from lines. Others are used to decorate text. Values suported are:underline, overline,none, line-through

Try it yourself


Line through

Text tranformation

text-transform property is used to transform text to uppercase or lowercase.
Try it yourself



Text spacing:

Letter spacing

letter-spacing property specifies space between the characters in the text.

Normal text

Spaced text

Line height

line-height specifies space between the lines.Default is 100%.

Normal text
Normal text

Spaced text
Spaced text

Word spacing

The word-spacing property is used to specify the space between the words .

Normal text
Normal text

Spaced text
Spaced text

Text indentation

The text-indent property is used to specify the indentation of the first line of a text (text shifts from normal margins):
Try it yourself

Indented by 50px

Indented by 10%

Text direction

The direction property is used to change the text direction of an element(left to right or right to left):

Try it yourself