a:hover does not work without href attribute in <a> ?

  • Thread starter Gabriel Lozano-Morán
  • Start date
G

Gabriel Lozano-Morán

Is there a reason why this does NOT work in IE6.0 ?

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

It only works when I add the href attribute:

<a href="">Some text</a>

I have already read that the <a> HTML tag is the only tag in IE that
supports the hover. I have created a treeview and all my <a> tags look like
this:

<div>
<a onClick="toggle(this)">Node 1</a>
</div>

In my toggle function I will set the style of the <div> to either
display:none or display:visible, that works. I need to hover of the <a> tag
so that whenever I move my mouse over Node 1 the background color changes.
How can I achieve this?

I am trying to create something similar like the treeview you can find at
http://msdn.microsoft.com/library/default.asp or does anybody know how the
deeptree.css looks like?

TIA

Gabriel Lozano-Morán
 
G

Gabriel Lozano-Morán

I have a found a solution by replacing the className of my node with another
class.

Gabriel
 
G

Guest

Gabrial,
There are actually a couple of ways to complete what you would like to do.
One example follows.

<html>
<head>
<style>
.ImOver
{
text-decoration: none;
}
.ImOff
{
text-decoration: underline;
}
</style>
</head>
<body>
<span onmouseover="this.className='ImOver'"
onmouseout="this.className='ImOff' onClick="Toggle(this)">Some text</span>
</body>
</html>
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top