Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS - Link Text Decoration Problems!

Status
Not open for further replies.

groovygarden

Programmer
Aug 23, 2001
63
0
0
Hi,

I'm trying to set it up so that the links on my nav menu are not underlined unless the user is hovering over them. To do this I added some stuff to my style sheet:
Code:
<style type=&quot;text/css&quot;>
<!--
  a:link { text-decoration:none }
  a:visited { text-decoration:none }
  a:hover { text-decoration:underline }
  a:active { text-decoration:none }
-->
</style>

...but there's a problem. It works fine on unvisted links (ie: there is no underline until I hover over the link) but on visted links the underline is there all the time.

Could anyone tell me what I'm doing wrong?

Thanks!
 
ooops, I meant to say that on visited links the underline is never there
 
If you want the line to be present for all visited links just change your declaration.

<style type=&quot;text/css&quot;>
<!--
a:link { text-decoration:none }
a:visited { text-decoration:underline }
a:hover { text-decoration:underline }
a:active { text-decoration:none }
-->
</style>

Now if you want this to happen only in your Navigation bar and not anywhere else on your page I would suggest you declare a class for the navigation links only and use the style on those. This way you have more options for the other &quot;regular&quot; links.

for example:
<a href=&quot;#&quot; class=&quot;navlink&quot;>HOME</a>

now on your style declaration

<style type=&quot;text/css&quot;>
<!--
.navlink a:link { text-decoration:none }
.navlink a:visited { text-decoration:underline }
.navlink a:hover { text-decoration:underline }
.navlink a:active { text-decoration:none }
-->
</style>

grtfercho.
 
Hi, thanks very much for the reply. I'm not sure I explained myself well... I only want the underline to appear when the mouse pointer is hovering over the link. As I said, this works ok with links which haven't been visited before, but on visited links, when I hover over them, the underline doesn't appear.

Thanks for the info on the css class - I'll def use that!
 
Ok now I understand better. However I tried your original code on IE6.0 and Netscape6.0 and I can see the line on visited or unvisited sites with no problems.
See if you don't have some other declaration overriding the
visited state.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top