CSS Text

Here's an overview of the various CSS text properties and their values

• Text Color (color)

• Text Alignment (text-align)

• Text Decoration (text-decoration)

• Text Transform (text-transform)

• Text Spacing

• Text Shadow (text-shadow)

1. Text Color (color)

The color property specifies the color of the text.

Values:

Named Colors: red, blue, green, etc.

Hex Codes: #ff0000 (red), #00ff00 (green), etc.

RGB: rgb(255, 0, 0) (red), rgb(0, 255, 0) (green), etc.

RGBA: rgba(255, 0, 0, 0.5) (red with 50% opacity)

HSL: hsl(120, 100%, 50%) (green), hsl(0, 100%, 50%) (red)

HSLA: hsla(120, 100%, 50%, 0.5) (green with 50% opacity)

2. Text Alignment (text-align)

The text-align property specifies the horizontal alignment of text within its container.

Values:

left - Aligns text to the left edge.

right - Aligns text to the right edge.

center - Centers text horizontally.

justify - Stretches text to align with both the left and right edges, adding space between words.

3. Text Decoration (text-decoration)

The text-decoration property is used to set decorations on text.

Values:

none - No decoration.

underline - Underlines the text.

overline - Adds a line above the text.

line-through - Adds a line through the text.

blink - Makes the text blink (not widely supported).

4. Text Transform (text-transform)

The text-transform property controls the capitalization of text.

Values:

uppercase - Transforms all letters to uppercase.

lowercase - Transforms all letters to lowercase.

capitalize - Capitalizes the first letter of each word.

none - No transformation (default).

5. Text Spacing

Text spacing properties adjust the space around and between text.

Properties:

letter-spacing - Adjusts the space between characters.

Values: Length (2px, 0.1em), normal

word-spacing - Adjusts the space between words.

Values: Length (4px, 0.2em), normal

line-height - Sets the amount of space between lines of text.

Values: Length (1.5em, 20px), Number (1.5), normal

6. Text Shadow (text-shadow)

The text-shadow property adds shadow effects to text.

Values:

<horizontal-offset> - Horizontal distance of the shadow.

<vertical-offset> - Vertical distance of the shadow.

<blur-radius> - Optional blur radius to soften the shadow's edges.

<color> - Color of the shadow.

Example:

<!DOCTYPE html>
<html>
<head>

  <title>CSS Text Properties</title>

  <style>
    .text-example {
      color: #3498db; /* Text color */
      text-align: center; /* Text alignment */
      text-decoration: underline; /* Text decoration */
      text-transform: uppercase; /* Text transform */
      letter-spacing: 2px; /* Letter spacing */
      word-spacing: 4px; /* Word spacing */
      line-height: 1.5; /* Line height */
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* Text shadow */
    }
  </style>

</head>

<body>

  <p class="text-example">This is an example of various CSS text properties.</p>

</body>
</html>

Output:

This is an example of various CSS text properties.