cssline-through

{CSS} A different color for the line which is drawn on a text by "text-decoration: line-through"?


Is it possible to change color of the line on wrapped text? I mean, e.g, a black text and a red line!?

enter image description here


Solution

  • You can do some CSS tricks to do it like this:

        .line-through-text {
            position: relative;
            color: blue;
        }
    
        .line-through-text:before {
            border-bottom: 2px solid orange;
            position: absolute;
            content: "";
            width: 100%;
            height: 50%;
        }
    <h2>
    Hello There! <span class="line-through-text">This is wrong,</span> This is correct
    </h2>