CSS Reference ยท Typography
The text-decoration-color property
Reference for the CSS text-decoration-color property: coloring underlines and strike-throughs separately from the text, currentcolor and live examples.
The text-decoration-color property sets the color of the underline, overline or line-through. By default the line has the same color as the text, but with this property you can give it an accent color, for example a colored underline under dark text. It has no effect when no decoration line is drawn.
CSS
a { text-decoration-line: underline; text-decoration-color: orange; }
Try it
Syntax
CSS
text-decoration-color: <color>;
- Initial value:
currentcolor - Applies to: all elements; also
::first-letterand::first-line - Inherited: no
- Animatable: yes, as a color
- Computed value: the computed color
Values
| Value | Description |
|---|---|
currentcolor |
Follows the text color. This is the default. |
<color> |
Any CSS color: names, hex, rgb(), hsl(), and so on. Transparent values make the line fainter or invisible. |
Usage notes
- A decoration needs a line. Set
text-decoration-line(or the shorthand) first, otherwise the color is not visible. - Decoration color is taken from the declaring element. An inline child with a different
colordoes not change the parent's line color; the parent's line is drawn with the parent's color ortext-decoration-color. - Shorthand resets it.
text-decoration: underlinesets the color back tocurrentcolor. - Contrast. If the line carries meaning, such as a link underline, keep enough contrast against the background. A very pale underline can disappear.
- Animation. You can transition the color for hover effects, as shown above.
- Not a text color. It does not change the letters themselves.
Browser support
Supported in current versions of all major browsers.
Related
text-decorationโ the shorthandtext-decoration-lineโ which lines are drawncolorโ the text color- Lesson: Styling Text