Underlining text, changing colors

H

Henry

How can I change the text in a link, originally displayed with the
"text-decoration:none" attribute to display an underline during the
onMouseOver event, and back to its original (non-underlined) state for
the onMouseOut? I'm pretty sure that it's of the format

document.<itemname>.attribute = value

but beyond that I'm not sure, and I can't find enough of a reference to
let me proceed. I'd also like, as an alternative, to be able to change
the font color instead of (or in addition to) just changing to underlining.

I'd appreciate it very much if anyone can provide a bit of code, or can
point me to some on-line reference that shows this. Thanks!


Henry
 
M

Mick White

Henry said:
How can I change the text in a link, originally displayed with the
"text-decoration:none" attribute to display an underline during the
onMouseOver event, and back to its original (non-underlined) state for
the onMouseOut?

<style type="text/css">
a:hover {
text-decoration: underline;
}
</style>

Mick
 
H

Henry Hayden

Thanks, Mick, for the speedy reply. I haven't used CSS before (I've had
some minor exposure to them, and I know that I should be using them...)
so I have a couple of questions.

First, does it matter where this snippet is placed on the HTML page? I
tried it in several locations (just inside the BODY and HTML tags, as
well as inside a <Table></TABLE>, but no soap.

Does it matter that the page where I'm trying to implement this is part
of a frameset? I have a links page (the left-most frame) where I want
this to be in effect.

Second- does the page's extension matter? Not only is this page part of
a frameset, it is also a JSP page. (Aha, the truth comes out!) Could
this be a factor, as well?

Certainly these effects are not crucial, but they are, I believe, pretty
understated and can give the page a more polished look. I'd like to get
this working, and appreciate your help.


Henry
 
K

Keith Bowes

Mick said:
a:hover {
text-decoration: underline;
}

But be warned, modern browsers will also display this effect for <a>s
with only a "name" or "id" attribute.
 
M

Mick White

Henry said:
Thanks, Mick, for the speedy reply. I haven't used CSS before (I've had
some minor exposure to them, and I know that I should be using them...)
so I have a couple of questions.

First, does it matter where this snippet is placed on the HTML page? I
tried it in several locations (just inside the BODY and HTML tags, as
well as inside a <Table></TABLE>, but no soap.

Inside said:
Does it matter that the page where I'm trying to implement this is part
of a frameset? I have a links page (the left-most frame) where I want
this to be in effect.

Second- does the page's extension matter? Not only is this page part of
a frameset, it is also a JSP page. (Aha, the truth comes out!) Could
this be a factor, as well? This should not matter

Certainly these effects are not crucial, but they are, I believe, pretty
understated and can give the page a more polished look. I'd like to get
this working, and appreciate your help.

Take a look:
http://www.mickweb.com/demo/hover.html

Mick
 
H

Henry Hayden

Thanks again!

I found, with the help of your last hint, what the problem was. In each
link, I had the following:

style: text-decoration: none

So... it was always going to be just that... none.
However, using the following:

<style type="text/css">
a{
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>

works just fine. Thanks again!

Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top