Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of "text-decoration-color" is not working

Tags:

css

I want to color the text decoration. I got a tutorial from w3schools

And tried this

text-decoration: underline;
text-decoration-color: #dddddd;

But it is not working. Is this not valid? Is there any other way to color the underline?

like image 960
Ranjit Avatar asked Aug 31 '17 08:08

Ranjit


People also ask

Which of the following is NOT used with text-decoration property?

4. Which of the following is not used with text-decoration property? Explanation: overline, underline, line-through properties are used to decorate the text. it will produce headings h1 with text having line-through, h2 with text having overline and h3 with text having underline.

What does text-decoration color do?

The text-decoration-color CSS property sets the color of decorations added to text by text-decoration-line . The color applies to decorations, such as underlines, overlines, strikethroughs, and wavy lines like those used to mark misspellings, in the scope of the property's value.

How do you change the color of text underline in HTML?

Change the underline to dots with the border-bottom style property a { text-decoration: none; border-bottom:1px dotted; }. Change the underline color by typing a { text-decoration: none; border-bottom:1px solid red; }. Replace solid red with another color.

How do you change the color of text underline in CSS?

Underline tag: To change the color of the underline, we need to add some styling using CSS (inline/internal/external). By default, the color of the underline is black. In CSS, we will use text-decoration property to style underline.


2 Answers

text-decoration-color has minimal browser support

Instead, you can use something like a span to re-colour your text:

p {
  color: red;  /* colour of underline */
  text-decoration: underline;
}

span {
  color: black; /* original colour of p */
}
<p><span>underline is red, text is black</span></p>
like image 168
Pete Avatar answered Oct 14 '22 16:10

Pete


Your code is likely to affect another class

p {
    text-decoration: underline;
    text-decoration-color: red!important;
}
<p>test</p>
like image 27
Farhad Bagherlo Avatar answered Oct 14 '22 14:10

Farhad Bagherlo