tags:

views:

417

answers:

3

When I have

<ul class="menu">
 <li><a href="bla">link</a></li>
</ul>

how do I make the LI-tag change a property (e.g. list-style-image) when is hovered (a:hover)?

+2  A: 

You can apply hover to the li as well:

ul.menu li:hover
 {
   list-style-image: url(highlight.gif);
 }

Note (Thanks to Andy E): :hover is not supported in IE6, and supported for links only in IE7. (See compatibility table here). There is a workaround for IE6 and 7 named whatever:hover.

Pekka
+1. For IE6 or other incompatible browsers you would have to achieve this in javascript.
Andy E
http://www.xs4all.nl/~peterned/csshover.html this guy has already done the hard work for you. I've used it to good effect.
Mauro
@Andy E Cheers for reminding me, edited my answer. @Mauro: Same link at the same time :)
Pekka
+1  A: 

On modern browsers you can use li:hover but on older ones you would have to use javascript.

Edit: By the way, if you set:

a {
    display:block;
}

you can do all the styling on the a and you don´t need to style the li.

jeroen
A: 

You can give add directly into anchor element which is sub element of li element

li a:hover { ..style.. }

Or you can add a class for anchor to do that

li a.HoverClass:hover { ..style.. }

There is a basic example here

Myra