CSS Text Effects

CSS text effects allow you to enhance and style text in various ways. These effects can make text more engaging, emphasize certain parts, or contribute to the overall design of a web page.

Common CSS Text Effects

  • Text Shadow: Adds shadows behind text.
  • Text Transform: Changes the case of text.
  • Text Decoration: Adds decorations like underline, overline, and strikethrough.
  • Text Stroke: Adds an outline around text (not widely supported).
  • Text Overflow: Manages how text is displayed when it overflows its container.

Text Shadow

The `text-shadow` property adds shadow effects to text. You can specify the horizontal and vertical offsets, blur radius, and color of the shadow.


/* Text Shadow Syntax */
text-shadow:    ;

        

Example: Text Shadow


/* Text Shadow Example */
.text-shadow-example {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

            

This text has a shadow effect.

Text Transform

The `text-transform` property changes the case of text. Common values are `uppercase`, `lowercase`, and `capitalize`.


/* Text Transform Syntax */
text-transform: ;

        

Example: Text Transform


/* Text Transform Example */
.text-transform-example {
    text-transform: uppercase;
}

            

This text is transformed to uppercase.

Text Decoration

The `text-decoration` property adds decorations to text, such as underline, overline, and line-through.


/* Text Decoration Syntax */
text-decoration: ;

        

Example: Text Decoration


/* Text Decoration Example */
.text-decoration-example {
    text-decoration: underline;
}

            

This text has an underline decoration.

Text Stroke

The `text-stroke` property adds an outline around text. Note that this property is not supported in all browsers.


/* Text Stroke Syntax */
-webkit-text-stroke:  ;

        

Example: Text Stroke


/* Text Stroke Example */
.text-stroke-example {
    -webkit-text-stroke: 1px black;
}

            

This text has a stroke effect.

Text Overflow

The `text-overflow` property controls how text is displayed when it overflows its container. Common values are `ellipsis`, `clip`, and `string`.


/* Text Overflow Syntax */
text-overflow: ;

        

Example: Text Overflow


/* Text Overflow Example */
.text-overflow-example {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

            

This is a very long text that will be truncated with an ellipsis when it overflows its container.