What You Want To Do: You have a horizontal (or vertical) menu list – when you hover over each item, you want it to “change” so that it indicates you’re mousing over it and you don’t want to use Javascript to accomplish this.
How To Do It: Instead of “swapping” out the original image and the image you see when you hover over, we’re going to make the original image go away. Think of this as a disappearing act.
First, I’ll show you what my horizontal list looks like:

The code:
So there I have inserted the images (normal state) into the <li> tags of my menu list. Next we’re going to add some CSS styles.
In my case, I want a horizontal list that does not have bullets, so I will need to make the <li> tags display inline, else it will give me a vertical list and style the list style type with none. Make sure you add the display block style to the li’s a element. If you don’t do that, the images will flicker when you hover over them. Try it with and without that style and you’ll see what I mean.
ul.headerMenuList li {
list-style-type: none; //gets rid of the bullets next to each item
float: left;
}
ul.headerMenuList li a {
display: block; //make sure you add this style, else the images will flicker when you hover over them!
}
ul.headerMenuList li img {
border: none;
}
You’re going to have different images for each menu item so you’ll have to give each item a separate class. Then in the CSS, you’ll give each of those classes a different background image to use which serves as the hover image.
Also, you’ll need to style the a element (with the image) when it’s being hovered over. When you hover over the item, you want to give it the effect of swapping/changing. What we’ll do here is add a visibility styling (hidden). That way, when you hover over the <li> (that already has a background image) it will hide the normal state image and display the hover image (background image).
Here’s my menu when you hover over “Home”:

The CSS looks like this:
ul.headerMenuList li.home {
background-image: url(/imgs/home_on.jpg);
background-repeat: no-repeat;
}
ul.headerMenuList li.home a:hover img {
visibility: hidden;
}
ul.headerMenuList li.findProviders {
background-image: url(/imgs/findProviders_on.jpg);
background-repeat: no-repeat;
}
ul.headerMenuList li.findProviders a:hover img {
visibility: hidden;
}
ul.headerMenuList li.findPayers {
background-image: url(/imgs/findPayers_on.jpg);
background-repeat: no-repeat;
}
ul.headerMenuList li.findPayers a:hover img {
visibility: hidden;
}
ul.headerMenuList li.news {
background-image: url(/imgs/news_on.jpg);
background-repeat: no-repeat;
}
ul.headerMenuList li.news a:hover img {
visibility: hidden;
}
ul.headerMenuList li.educationalTools {
background-image: url(/imgs/educationalTools_on.jpg);
background-repeat: no-repeat;
}
ul.headerMenuList li.educationalTools a:hover img {
visibility: hidden;
}
With the Javascript method I previously posted, you have to preload the images. With this CSS method, you do not have to preload any images. The concept of this method is easy to grasp – you have an image and then you have a different image you want to reveal when you mouse over it. For people (like me) who don’t want to mess with Javascript, this is definitely a solid method!
Note: This method is not compatible with IE6 as it does not support attribute selectors (a:hover) nor context-dependent styles (a:hover img). To hell with IE6.