While designing a site that needed a lot of mouse over text buttons (images with a little symbol and some text to be hi-lighted when hovered) I came up with a sweet little trick. Instead of using java-script to swap images I made the text to be hi-lighted invisible (gif transparent), and set the background to change on a:hover in the CSS. The effect is exactly the same but without an extra image to load and without the Java-script. In total, a lot of bytes less to load.
You can do the same without the transparent gif, just use/don't use the background-image in your a:link or a:hover.
Creating an example I found what appears to be a bug in FireFox handling of background colors. Try the example using both IE and FF and you'll see what I mean. Try it using Opera and you'll be amased how wrong it can get. After creating this example I looked at the page I was constructing and there it works for IE and FF so I added an image from that page for reference. Opera messes up the example file in a major way. However on the site's page there are two rows of images and there Opera only adds a 1 px line below the lower image. To conclude, if you want to highlight small (height wise) images and do not care about visitors using Opera then this might work for you. But if you want to use a larger image then use Java-script and preload your images. That is if noone can solve this and get it to work in both IE and FF for larger images. See update further down
But if you have a background image then the visitor must load that, using just transparent gif and background color you don't need that. But as I posted above, there seems to be some problem with the handling of background colors. This is not the update, it's even further down
To work in Firefox you would need to set your <a> to {display:block;} and add a width attribute to match your image. This will undoubtedly display differently in IE.
Perfect, now it works like it should in all browsers. Just wait a sec and I'll update the example, or rather I'll make a new to show how it should be done Edit: Here is the new example.
It will work the same way in IE if you set width in pixels - %'s won't work because of a bug in IE. Edit: here's a little example: http://forums.digitalpoint.com/showpost.php?p=87109 J.D.
Thought there was something - didn't have time to check before posting. On the ball as ever J.D. Mick