text formatting CSS

By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022

Text-Color

 

How can we format text in CSS?

We can format text by applying different properties on the text.

Example 1:

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

Output:

This is heading 1


Example 2:

<html><head>
<style>h1 {
color: green;text-align: center;
}
</style>
</head>
<body><h1>This is heading 1</h1></body></html>

Output:

This is heading 1

Explanation:

Properties of text-align:

  • center โ€“Text moves to the center
  • left โ€“ Text moves to the left
  • right โ€“ Text moves to the right
  • inherit โ€“ Inherit value from its parent element
  • justify โ€“ Text is decorated in a consistent way and moves to the left and right corners.

Enlist some of the properties of text CSS?

 Property Description
color Set the color to the text
line-height Sets the height for text line
direction Sets the text direction
letter-spacing Sets the spacing between alphabets of the words
 word-spacing Sets the spacing between all words

 

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials