7 CSS Text Effects - Reference

Text Effects

Add visual flair to text with shadows, decorations, and special effects

← Back to Reference

What are Text Effects?

Text effects are CSS properties that add visual enhancements to text beyond basic styling. They include shadows, underlines, outlines, and overflow handling. Used thoughtfully, text effects can emphasize content and improve visual appeal.

Key Principle: Use text effects to enhance readability and draw attention, not to distract.

text-shadow

Adds shadow effects to text.

text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);

Syntax: horizontal vertical blur color

Multiple shadows: Comma-separated list

Example: text-shadow: 1px 1px 2px black, 0 0 25px blue;

text-decoration

Adds lines to text (underline, overline, line-through).

text-decoration: underline;
text-decoration: line-through red wavy;

Values: none, underline, overline, line-through

Extended syntax: line style color

Styles: solid, dotted, dashed, wavy, double

text-decoration-color

Sets the color of text decoration lines.

text-decoration-color: red;

Use: Different color for underline than text

text-decoration-thickness

Controls the thickness of decoration lines.

text-decoration-thickness: 3px;

Values: auto, from-font, length (px, em)

text-overflow

Controls how overflowing text is displayed.

text-overflow: ellipsis;

Values: clip (cut off), ellipsis (...)

Requires: white-space: nowrap; and overflow: hidden;

white-space

Controls how whitespace and line breaks are handled.

white-space: nowrap;

Values: normal, nowrap, pre, pre-wrap, pre-line

nowrap: Prevents text from wrapping to new line

pre: Preserves whitespace like <pre> element

word-wrap / overflow-wrap

Allows long words to break and wrap onto the next line.

overflow-wrap: break-word;

Values: normal, break-word, anywhere

Use: Prevents long URLs or words from breaking layout

text-indent

Indents the first line of text in a block.

text-indent: 2em;

Common use: Paragraph indentation

Negative values: Creates hanging indent

-webkit-text-stroke

Adds an outline to text characters (webkit browsers).

-webkit-text-stroke: 2px black;

Syntax: width color

Note: Vendor-prefixed, may not work in all browsers

← Back to Reference