CSS text-decoration Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The text-decoration property is a shorthand for decorative lines on text. It sets text-decoration-line, text-decoration-style, text-decoration-color, and text-decoration-thickness.

Common uses are underlines on links, strike-through for deleted text, and none to remove a default underline. Decorations paint across descendant text, so a child cannot erase a parent line with none.

Standard-track.

Not deprecated as a property. Baseline widely available for line, style, and color. Thickness in the shorthand is newer and less uniform.

Deprecated blink

Do not use text-decoration: blink. It is deprecated, poorly supported, and inaccessible.

CSS Syntax

syntax.css
text-decoration: <line> || <style> || <color> || <thickness> | initial | inherit;

Omitted parts reset to their initial values. Prefer a longhand when you only want to change one piece.

Property Values

ValueDescriptionTry it
noneNo decoration lineTry it
underlineLine under the textTry it
line-throughStrike-through across the textTry it
underline wavy redLine + style + color in one ruleTry it
initialResets the longhands to their initialsTry it
inheritTakes the parent’s text-decorationTry it

How to Use text-decoration

Pick the line first, then add style or color only when you need them.

  1. Set a line keyword such as underline, overline, line-through, or none.
  2. Optionally add a style (solid, wavy, dashed) and a color.
  3. Use longhands when you must keep thickness or color while toggling only the line.
  4. Tune underline placement with text-underline-offset when needed.
PieceRequired?Role
LineYesnone, underline, overline, line-through
StyleNosolid (default), wavy, dashed, dotted, double
ColorNoDefaults to currentColor
ThicknessNoLength or auto; shorthand support varies

Live Preview

Same sentence. Change only text-decoration.

Line keywords can combine (for example underline overline). Style and color are optional extras.

Text

Sample text decoration

text-decoration: underline

CSS Examples

Each snippet focuses on text-decoration. Use Try It Yourself for a live editor.

Example 1 — Underline Text

Draw a solid underline with one keyword.

CSS
<style>
  p {
    text-decoration: underline;
  }
</style>

<p>Sample text decoration</p>
Try It Yourself

How It Works

  1. Choose a line. underline sets text-decoration-line.
  2. Accept defaults. Style stays solid and color stays currentColor.
  3. Shorthand reset. This also sets thickness and the other longhands to their initials.
  4. Where it paints. The line follows the text of this element and its descendants.

Example 2 — Remove a Link Underline

Turn off the default underline on an anchor.

CSS
<style>
  a {
    text-decoration: none;
  }
</style>

<a href="#">Plain link</a>
Try It Yourself

How It Works

  1. Target the link. Browsers underline a elements by default in most stylesheets.
  2. Clear the line. text-decoration: none sets the line longhand to none.
  3. Keep meaning clear. Color or weight can still show that the text is a link.
  4. Hover tip. Many designs restore underline on :hover / :focus-visible.

Example 3 — Style and Color Together

Combine line, style, and color in one shorthand value.

CSS
<style>
  p {
    text-decoration: underline wavy red;
  }
</style>

<p>Sample text decoration</p>
Try It Yourself

How It Works

  1. Line first. underline chooses where the decoration sits.
  2. Style second. wavy sets text-decoration-style.
  3. Color third. red sets text-decoration-color (order of style and color is flexible).
  4. Still a shorthand. Any omitted longhand, including thickness, resets to its initial value.

Edge Cases & Pitfalls

If a decoration looks wrong, one of these is usually why.

child

Children cannot erase a parent line

A parent underline still paints through a child. text-decoration: none on the child does not remove it; the child can only add another decoration.

shorthand

Shorthand resets omitted parts

Setting text-decoration: underline on hover can wipe a custom thickness or color. Use text-decoration-line when you only want to toggle the line.

thickness

Thickness in the shorthand is uneven

Including a length in text-decoration is newer. Prefer the text-decoration-thickness longhand when thickness must stick.

blink

Avoid blink

The blink value is deprecated and should not be used in production CSS.

offset

Gap under text is a different property

Move an underline away from glyphs with text-underline-offset, not with text-decoration alone.

Browser Support

text-decoration is a browser CSS property for text lines. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since Jul 2015

text-decoration

Line keywords: all modern browsers and IE. Style/color: modern evergreen browsers. Thickness in shorthand: Chrome 87+, Firefox 70+, Safari 26.2+, Edge 87+.

97% Line / style / color support
Google Chrome 1+ line · style/color 57+
Full support
Mozilla Firefox 1+ line · style/color 36+
Full support
Apple Safari 1+ line · style/color 12.1+
Full support
Microsoft Edge 12+ line · style/color 79+
Full support
Opera Line long · style/color 44+
Full support
Samsung Internet Line long · style/color 7+
Full support
Internet Explorer Line only
Partial
text-decoration Widely supported

Bottom line: Safe for underline, none, and line-through everywhere. Use longhands for thickness when you need older Safari or maximum consistency.

Key Takeaways

  • Role: shorthand for line, style, color, and thickness on text.
  • Common values: none, underline, line-through, underline wavy red.
  • Initial line: none. The longhands are not inherited.
  • Pitfall: a child none does not cancel a parent decoration.

One line: text-decoration draws (or clears) the line; longhands keep style, color, and thickness under control.

Frequently Asked Questions

It is a shorthand for decorative lines on text. It sets text-decoration-line, style, color, and thickness in one declaration.
The longhands default to none (line), solid (style), currentColor (color), and auto (thickness). Writing text-decoration: none turns the line off.
Set text-decoration: none on the link. Remember the shorthand also resets style, color, and thickness to their initials.
Decorations paint across descendant text. text-decoration: none on a child does not erase a parent decoration. The child can only add another line.
No. blink is deprecated, poorly supported, and hard to use accessibly. Avoid it.
Basic line values are universal. Style and color are widely supported in modern browsers. Thickness in the shorthand is newer (Chrome 87+, Firefox 70+, Safari 26.2+). It is a browser CSS property, not a Node.js feature.

Next: text-decoration-color

Learn how to color the decoration line without changing the text color.

text-decoration-color tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful