views:

586

answers:

4

I wonder if there is any trick to solve this problem.

I have my link as below text and want to change the underline color.

This link contains in many lines which needs to change the underline color to be lighter than the existing one

Using border bottom is not the way to solve this because multiple lines.

are there any trick to solve this?

EDIT

@Paolo Bergantino: It works with IE8 , is it possible to hack with IE6,7?

A: 

the underline on links is done using the text-decoration css style, i think it's the same color as the text.

if you set the text-decoration to none then add a border-bottom you can change the color with the border-color style.

John Boker
I have multiple line text, so border bottom doesn't solve
pang
A: 

Underlined, being a text attribute, inherits the text's color. So I doubt there is a way to explicitly change the underline color without also changing the text color.

Joey
+7  A: 

If what you mean is a different underline color than what the text is, the only thing I can think of is to add a span around the link:

<span class='underline'>
    <a href="#">this just<br>a test<br>of underline color</a>
</span>

And then the CSS:

span.underline { 
    color: red; 
    text-decoration: underline; 
} 
span.underline a { 
    color: blue; 
    text-decoration: none; 
}

And you get what you want.

EDIT:

Testing this a little further, it is not working for me on IE. If you add border-bottom, however, it surprisingly does work in all browsers, except that IE does not put a border under the last one. I will try to dig a little deeper to see if there's a cross-browser way to do this...

Paolo Bergantino
This example could be even cooler if every major browser supported the `:before` and `:after` pseudo-selector.
Dan Herbert
+1 for answering the actual question asked.
Robert Harvey
That's going to affect all link selectors, so a user won't be able to distinguish what link they have visited.
OMG Ponies
this is interesting... I'm surprised it works :)
Jimmy
I shall be making a note of this for future reference, its so simple yet works perfectly.
MitMaro
@Paolo Bergantino : thanks for spending time on this
pang
+1  A: 

The Underlining of links will always be the same color as the text.

Chris Pietschmann