I would like to, within one anchor </a>
, have two different underline colors. Like so:
<a href="somehref">
<span>This text should underline RED on `a` hover</span>
<span>This text should underline GREY on `a` hover</span>
</a>
I can add text-decoration
to each span on hover but this causes each line to hover individually. I want it so that when I hover over anywhere in the </a>
both spans underline with their font color
inherited.
Is this possible?
Note: I'm aware of text-decoration-color
but due to limit support I cannot use it.
Change the underline color by typing a { text-decoration: none; border-bottom:1px solid red; }. Replace solid red with another color.
To remove underline from a link in HTML, use the CSS property text-decoration. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property text-decoration to remove underline from a link in HTML.
Some thing like this? You can use the anchor's :hover
CSS pseudo class to style it's child and descendant.
Here is an reference to CSS child and descendant selectors.
a {
color: black;
text-decoration: none;
}
a span:first-child {
color: red;
}
a span:last-child {
color: grey;
}
a:hover span {
text-decoration: underline;
}
<a href="somehref">
<span>This text should underline RED on `a` hover</span>
<span>This text should underline GREY on `a` hover</span>
</a>
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