Text Formatting Selectors in CSS :

PropertyDescription
colorSets the color of text
directionSpecifies the direction of writing
letter-spacingSpecifies the space between characters in a text
line-heightSpecifies the line height
text-alignSpecifies the horizontal alignment of text
text-decorationSpecifies the decoration added to text
text-indentSpecifies the indentation of the first line in a text-block
text-shadowSpecifies the shadow effect added to text
text-transformControls the capitalization of text
vertical-alignSets the vertical alignment of an element
white-spaceSpecifies how white-space inside an element is handled
word-spacingSpecifies the space between words in a text

Property 1 : Color

<html>
    <head>
        <style>
            h1 {
                color:#ff0000;
            }
        </style>
    </head>
    <body>
        <h1>This is heading 1</h1>
    <body>
</html>

Explanation :

  1. color property is used to specify the color of the text in CSS.
  2. color property can be used in many ways -
body {
    color: blue;
}
h1 {
    color: #00ff00;
}
h2 {
    color:rgb(255,0,0);
}
  1. We can specify color by direct name,using hex value or by specifying the color composition.

Property 2 : Text Alignment

h1 {
    text-align: center;
}
h1 {
    text-align: right;
}
h1 {
    text-align: justify;
}

We can set alignment of the text in CSS using text-alignment property. CSS text alignment can have different values -

  1. Centered
  2. Aligned to left
  3. Aligned to right
  4. Justified

Property 3 : Text Decoration

h1 {
    text-decoration: overline;
}
h2 {
    text-decoration: line-through;
}
h3 {
    text-decoration: underline;
}
h4 {
    text-decoration: blink;
}

We can decorate text using this property. We can show underline to particular text or we can hide decoration using this property.