Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't a:hover work on an anchor without an href attribute?

In my application, I can't get the a:hover css style to work when my anchor tag doesn't have an href attribute.

Is there any reason for this?

like image 507
omg Avatar asked Jun 24 '09 20:06

omg


2 Answers

IE doesn't support a:hover in a tag without href. You can use href="#" or href="Javascript:void(0);" however this last option probably won't work on IE6 either.

Or use Javascript mouseover/mouseout.

like image 68
David Aleu Avatar answered Sep 23 '22 11:09

David Aleu


Hover is intended for links. Without the HREF the tag is simply an anchor.

In other words...

<a name="target"></a>

is an ANCHOR within a page that...

<a href="#target">go there</a>

would be a LINK to.

Since ANCHORs don't have visual representation on a page.. a :hover would be useless.

like image 44
Joe Davis Avatar answered Sep 22 '22 11:09

Joe Davis