DEV Community

Cover image for Text Properties in CSS
Rakshambika
Rakshambika

Posted on

Text Properties in CSS

Text Properties:

Text properties in CSS are used to control the appearance, alignment, spacing, decoration, and transformation of text on a webpage.

1.color:

color property is used to set the color for the text inside an element.

p{
   color:red;
}
Enter fullscreen mode Exit fullscreen mode

2.text-align:

text-align property is used to align the text horizontally.

h1{
   text-align:center;
}
Enter fullscreen mode Exit fullscreen mode

Values:
- left
- right
- center
- justify


3.text-decoration:

text-decoration property is used to add or remove decorations such as underline, overline or line-through from the text.

#heading{
text-decoration:underline;
}
Enter fullscreen mode Exit fullscreen mode

Values:

   - none – Removes any text decoration
   - underline – Adds a line below the text
   - overline – Adds a line above the text
   - line-through – Adds a line through the middle of the text
Enter fullscreen mode Exit fullscreen mode

4. text-transform:

text-transform property is used to change the text from one case to another.

h2 {
text-transform:uppercase;
}
Enter fullscreen mode Exit fullscreen mode

Values:

  • uppercase
  • lowercase
  • capitalize
  • none

5.letter-spacing:

letter-spacing property is used to provide the space between the letters in the text.

p {
    letter-spacing: 2px;
}
Enter fullscreen mode Exit fullscreen mode

6.word-spacing:

word-spacing property is used to provide space between the words in the text.

p {
    word-spacing: 5px;
}
Enter fullscreen mode Exit fullscreen mode

7.text-indent:

text-indent property is used to adding space at the beginning of a line or paragraph.

p {
    text-indent: 50px;
}
Enter fullscreen mode Exit fullscreen mode

Example:

Without Indentation:

This is the first line of the paragraph.
This is the second line of the paragraph.

With text-indent: 50px:

           This is the first line of the paragraph.
This is the second line of the paragraph.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)