1

How can I change the color of the underline only, when the use mouse hovers a string?

Here is the site, in the right corner u will see the menu.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
zan
  • 99
  • 3
  • 9

5 Answers5

2

text-decoration-color is only supported by Mozilla.

What I would suggest is use

1) border-bottom

a:hover
{
text-decoration: none;
border-bottom: 1px solid blue;
}

OR

2) background image in CSS.

a:hover
{
    text-decoration: none;
    background: url('image.jpg') #FFF repeat-x;
}

Make the image suiting your need. And position the background image to bottom. And rest of the color can #FFF.

Leo T Abraham
  • 2,407
  • 4
  • 28
  • 54
1

You can use three methods:

  1. Using text-decoration-color.

    a:hover {text-decoration-color: green; color: blue;}
    
  2. Using two DOM elements!

    a:hover {color: green; text-decoration: underline;}
    a:hover span {color: blue;}
    
  3. Using a border-bottom:

    a:hover {border-bottom: 1px solid green; color: blue;}
    

All the three methods give the same output. Colour with a blue and line with a green!

Also, along with the above methods, there are a lot: Crafting link underlines. Thanks to srekoble.

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
  • 1
    There more than 3 ways, for example gradient have a look at this great article https://medium.com/designing-medium/7c03a9274f9 – Vangel Tzo Apr 24 '14 at 12:40
1

Try this

<style type="text/css" media="screen" />
a {
text-decoration: none;
}
a:link {
color: #0000FF;
border-bottom: 1px solid #0000FF;
}
a:visited {
color: #0000FF;
border-bottom: 1px solid #C0C0C0;
}
a:active {
color: #FF0000;
border-bottom: 1px solid #FF0000;
}
a:hover {
color: #000000;
border-bottom: 2px solid #DD0000;
}
</style>
<a href="http://www.google.com/">Hover this link to view the color change</a>
Mad Angle
  • 2,347
  • 1
  • 15
  • 33
0

you can change it simply by adding

a:hover{
    text-decoration:underline;
    border-bottom: 0px solid blue;
}
shakhrillo
  • 37
  • 5
0

I hope it's more easy to add a color of a border-bottom.

Try it

Luiggi
  • 358
  • 4
  • 12