learn2kode.in

CSS Text

CSS Text properties allow you to control how text appears on a webpage. These properties help improve readability, spacing, alignment, decoration, and overall design. Text styling is an essential part of web design because it affects user experience and visual structure.

1. Text Color

The color property is used to set the text color. You can use color names, HEX, RGB, or HSL values.

2. Text Alignment

The text-align property aligns text inside an element.

Values include:

h1 {
  text-align: center;
}

3. Text Decoration

Used to add lines to text.

Common values:

Example

a {
  text-decoration: none;
}

4. Text Transform

Changes the case of text.

Values

h2 {
  text-transform: uppercase;
}

5. Text Spacing

Letter Spacing

Controls the space between characters.

p {
  letter-spacing: 1px;
}

Word Spacing

Controls the space between words.

Line Height

Controls spacing between lines.

6. Text Shadow

Adds shadow effects to text.

h1 {
  text-shadow: 2px 2px 5px gray;
}

7. Text Indent

Indent the first line of a paragraph.

8. Direction & Writing Mode

CSS supports text direction and vertical text.

Vertical text example:

p {
  writing-mode: vertical-rl;
}

9. White-Space Handling

Controls how text wraps or collapses. Common values:

div {
  white-space: nowrap;
}

Summary

CSS Text properties help improve:

They are a core part of modern web design.