View Full Version : An IE7 hover problem

12-02-2009, 04:54 PM
I have a problem getting IE7 to apply a hover style and no matter what I have tried or where I have googled I haven't been able to come up with a workaround. The code works on all other browsers and on IE8, but from what I have read, IE7 is pretty buggy in this area.

I've extracted this code from a much larger app in order to isolate the problem. What I'm down to is as follows:

<td width="120" align="center" valign="top">
<div class="IE7Open"><a class="IE7OpenLink">TentName</a></div>

The style is:

.IE7Open {border-style: solid; border-color: #003399; border-width: 1px; background-color:#a8cefc;
width: 100px; height: 16px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; margin-bottom: 5px;}
.IE7OpenLink {text-decoration:none;}
a:hover.IE7OpenLink {color: #C700FF; font-weight:bold; cursor:pointer; }

I know it may look a little odd extracted like this, but trust me, the source page is far more complicated and tough to read.

Any suggestions on how to get IE7 to apply the hover?

12-02-2009, 05:51 PM
Try this instead:

a.IE7OpenLink:hover{/*whatever here*/}

12-02-2009, 05:57 PM
No, that didn't change anything. Still works fine in all places except IE7.

Thanx for suggesting.

12-02-2009, 06:57 PM
Hello jpullam,
What DocType is your site using? There is some advantage to be gained in CSS conformity by using a Strict DocType when dealing with hover issues, as well as many other issues, in IE7.


12-02-2009, 07:57 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 //EN" "http://www.w3.org/TR/html4/strict.dtd">

12-02-2009, 08:40 PM
I've gotten it down to its most basic form and still it won't work!!

The page has

<a class="IE7OpenLink">Any Name</a>

and CSS is

a.IE7OpenLink:hover {text-decoration:none; color: #C700FF; font-weight:bold;}

and it doesn't work in IE7. It seems so elemental. In fact other hover's do work in IE7. What am I missing?

12-02-2009, 08:53 PM
<a class="IE7OpenLink">Any Name</a> is invalid!

Try this in IE7 -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
a.IE7OpenLink:hover {text-decoration:none; color: #C700FF; font-weight:bold;}
<a href="#" class="IE7OpenLink">Any Name</a>

12-03-2009, 09:35 PM
I'm not sure that I agree that <a class="IE7OpenLink">Any Name</a> is really invalid. The original HTML contained an onclick handler (and a lot more) and I just removed things to get down to the real basics that showed where the problem actually was. But if you are saying that putting in an href="#" will fix it, then I'm glad to do that.

And yes, it seems that did fix it, so thanks a lot.

12-03-2009, 10:48 PM
IE in general doesn't handle the DOM well at all so you probably need a href for it to fill the tree out as best it can.