I’d like to have gray text with a red strike-through, but this style doesn’t work:
color: #a0a0a0; text-decoration: line-through 3px red;
What am I doing wrong?
The text-decoration-color property sets the color of the underline, overline, or line-through on text with the text-decoration property applied. It can also set the underline color on links.
You can also use the <del> tag for crossed-out text, which is more semantically correct. However, the <del> tag doesn't always work in all browsers. So, if you need to ensure that your text is readable in any browser, the <strike> tag is a good fallback. CSS can also be used to style strikethrough text.
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.
Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.
You can simulate the desired effect with two nested elements, e.g.:
span.inner { color: green; } span.outer { color: red; text-decoration: line-through; }
<span class="outer"> <span class="inner">foo bar</span> </span>
jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With