🎨 Understanding text-decoration-color in CSS

πŸ“Œ Introduction

The text-decoration-color property in CSS allows you to set the color of text decorations such as underline, overline, andline-through. It works together with text-decoration-line andtext-decoration-style to fully customize text decoration. 🎨

🧠 What Does text-decoration-color Do?

This property simply defines the color applied to the text decoration. Without it, the decoration inherits the text’s current color. Using this property lets you create beautifully styled links, headings, and highlight effects.

✨ Syntax

Basic Syntax

text-decoration-color: color;

🎯 Example Usage

Setting Underline Color

.styled-text {
  text-decoration-line: underline;
  text-decoration-color: red;
}

This will underline the text in red even if the text color itself is different.

πŸ§ͺ More Examples

1. Different text vs underline color

Custom underline color

.custom {
  color: black;
  text-decoration-line: underline;
  text-decoration-color: blue;
}
2. Using hex, rgb, hsl, and named colors

Various color formats

.example1 { text-decoration-color: #ff5733; }
.example2 { text-decoration-color: rgb(30, 144, 255); }
.example3 { text-decoration-color: hsl(200, 80%, 50%); }
.example4 { text-decoration-color: gold; }

πŸ“‹ Supported Values

ValueDescription
colorAny valid CSS color value
currentColorInherits the current text color
inheritInherits from parent element
initialSets to default value
unsetResets to inherited or initial

⚠️ Important Notes

Note

Note:text-decoration-color only works whentext-decoration-line is applied. Without a line, the color won’t appear.

🌟 Real-World Use Case

This property is especially useful when designing links with a custom underline color that doesn’t match the text color β€” a modern UI trend seen in blogs and editorial websites.

Modern Link Style

a {
  color: #222;
  text-decoration-line: underline;
  text-decoration-color: #ff4d4d;
  text-decoration-thickness: 2px;
}
>>β€œGood design is obvious. Great design is invisible β€” but your underline color can still shine.” ✨

πŸŽ‰ Conclusion

The text-decoration-color property gives you fine-grained control over how text decorations look. By pairing it with text-decoration-line andtext-decoration-style, you can craft beautiful, readable, and modern text elements. πŸš€