CSS: Line-through with a color different from the text color?

Tony the Pony picture Tony the Pony · Dec 6, 2010 · Viewed 63.3k times · Source

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?

Answer

Benjamin Wohlwend picture Benjamin Wohlwend · Dec 6, 2010

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