The hover selector is wonderful css technique that can add style to an element as well as improve usability. Most people use it to style links so that users are aware of the link they are hovering over. One common technique is to underline all of the links on a page and then remove the underline when a user hovers over the link. Again this improves both the look of the page as well as usability. Another technique I enjoy is changing the background color of a row when a user hovers the row. This can be achieved by simply using the :hover pseudo-class. Here is a screen shot of my example.
The problem with this technique is it works in all browsers except IE6, of course. IE6 only supports the :hover pseudo-class on anchor () tags. So how can we fix this so that all users see our row highlight? There are at least 2 solutions that I know of. The first involves a little JavaScript and I found a great example of how to do this on www.sidesofmarch.com. The example basically uses prototype to grab all of the rows and apply a class to them. You could easily do this in jquery, ext or spry as well.
The second solution is to use the csshover behavior that was developed by Peter Nederlof. IE supports so called behaviors; .htc or .hta files that can be attached to specific elements using css making it possible to let these elements behave in a special way. You can visit Peter's site to learn more about it. Once you download the csshover.htc file you simply add the following to your stylesheet. < This will look parse your stylesheet and search for all :hover rules and replace the rule with a scripted event. I really like this solution because it enables you to use standard code for IE7 and FireFox while using this to apply a "fix" to IE6. Here is the final code for my example, enjoy!
index.cfm
stylesheet.css

#1 by Dondre on 1/22/08 - 3:32 AM
#2 by Roger Gordon on 1/28/08 - 11:24 AM
#3 by Andy on 2/17/08 - 5:45 PM
#4 by Livingston Samuel on 2/20/08 - 8:46 AM
http://blog.delivi.info/javascript/hover-for-non-a...
#5 by Donald Howe on 3/26/08 - 12:07 PM
This is the site; http://dev-westfield.virtualhorizons.com/careers/w...
The menu rollovers work fine but the people rollovers do not work in IE6. I am using the :hover in my CSS.
Any help appreciated.
#6 by webfairy on 9/1/08 - 7:59 PM
#7 by Larry on 11/6/08 - 12:42 PM
I just needed a hover effect on a single div, so based on everything i learned here i came up with the following code, which works in IE and Firefox:
<div id="foo" onMouseOver="this.className += ' ' + 'hover';" onMouseOut="this.className = this.className.replace('hover', '');">
and in your styles you just need
#foo { whatever }
and
#foo.hover { whatever }
Thanks again, because i never would have figured this out without the info here!
#8 by Lostboy79 on 1/13/09 - 10:21 AM
http://www.basictips.com/table-cell-background-col...
#9 by Pete on 1/22/09 - 7:37 PM
Larry's solution posted 11/6/08 works great when you have a small number of divs to tweak and doesn't require the csshover3.htc file.
#10 by Will on 9/15/09 - 4:30 PM
#11 by Livingston Samuel on 4/30/10 - 3:11 PM
this implementation is more efficient; as it uses javascript conditional comments, so that only IE recognizes and parses the code and it is micro-optimized.
More over using behavior htc will invalidate your css and has it's own performance issues.
#12 by Rob on 6/18/10 - 8:13 AM
Try this:
body { _behavior:url("csshover.htc"); }
This way IE 7 and 8 don't bother with it.
Or if you want just IE6 and 7
body { *behavior:url("csshover.htc"); }
enjoy