Course contentsShow
← Web Development
Lesson 172 of 2,9823. CSS FundamentalsFree lesson

Text Decoration and Underlines

Add or remove underlines, overlines, and strikethroughs with text-decoration properties.

Text Decoration and Underlines

You'll learn how to control underlines, overlines, and strikethroughs on text using CSS text-decoration properties.

What Is Text Decoration?

Text decoration lets you add or remove visual lines that embellish text. Think of it like the formatting toolbar in a word processor—you can underline words for emphasis, strike through text to show deletion, or add lines above text. In CSS, the text-decoration property family gives you precise control over these visual effects.

The Core Properties

The main property is text-decoration, which controls the line, style, and color all at once:

a {
  text-decoration: underline; /* adds underline */
}

.strikethrough {
  text-decoration: line-through; /* crosses out text */
}

.overline {
  text-decoration: overline; /* line above text */
}

.plain {
  text-decoration: none; /* removes all decoration */
}

You can also combine effects:

.fancy {
  text-decoration: underline overline;
}

Common Use Case: Styling Links

By default, links (<a> elements) have underlines. You'll often want to remove them:

a {
  text-decoration: none; /* removes default underline */
}

a:hover {
  text-decoration: underline; /* underline on hover only */
}

Fine-Tuning with Sub-Properties

For more control, use individual properties like text-decoration-line, text-decoration-style (solid, wavy, dotted, dashed, double), and text-decoration-color—but remember these build on the foundations you're currently learning.

Key Takeaway: Use text-decoration to add or remove underlines, overlines, and strikethroughs—it's essential for styling links and emphasizing text visually.