absolute positioned anchor tag (with no text) not clickable in IE

I have two anchors positioned absolute on top of an image, the links are clickable in other browsers (Chrome, FF, Safari) but not in IE (tested in 8 & 9 so far)

The strange thing is if I give the links a background-color they are clickable, however if the background-color is set to transparent (which is what I want) they are no longer clickable, I've also tried setting zoom:1 but no luck. I guess the hasLayout bit in IE went away with IE 8/9 so guessing zoom doesn't matter now for this kind of issue.

Any ideas to make these links show up in IE 8/9 with a transparent bg?

Here's the fiddle I've been working with: jsFiddle example

I have the following HTML layout:

<div id="content">
    <img src="http://placehold.it/724x300" width="724" height="300" alt="woot" />

    <div id="countdown"></div>

    <a id="link1" href="http://www.stackoverflow.com" title="link1"></a>
    <a id="link2" href="http://www.stackoverflow.com" title="link2"></a>
</div>

and CSS:

body {text-align:center;}
#content {position:relative; width:724px; height:300px; margin:0 auto;}

#countdown {position:absolute; width:650px; height:110px; top:100px; left:30px; background-color:blue;}

#link1 {position:absolute; width:520px; height:35px; bottom:20px; left:0;}
#link2 {position:absolute; width:200px; height:35px; bottom:20px; right:0;}

I have had this exact problem before and it has always annoyed the hell out of me. I'm never sure why it happens, but I always create a 1px by 1px transparent PNG (or GIF) and use that in your background declaration like so:

a { background: url("/path/to/image.png") 0 0 repeat; }

Hope this helps.

PS - Don't specify any actual background colour with this. Just use the example above and it should work.

In addition to this, try and set your anchor tags to display as block and perhaps also insert a non-breaking space in them (since they are empty at the moment and that might be tripping IE up):

a { display: block; background: url("/path/to/image.png") 0 0 repeat; }

<a href="#">&nbsp;</a>

You can do it using the mentioned background-image trick. When you do not want to use a transparent image for this, just use an unknown scheme or about:blank in the image URL.

a { background-image: url("iehack:///"); }

or

a { background-image: url("about:blank"); }

This works at least in IE 8 + 9 (the only IEs I tested) and in current versions of Firefox and Chrome. It is still valid CSS and causes no additional traffic. The first "hack" may give a JS error in Chrome (and maybe others) when using jquery. The latter only (but surely) gives a MIME-Type warning in Chrome due to the wrong MIME-Type of the about:blank document.


Transplanted from a comment I posted some time ago.

Little longer, but still no traffic, base 64 encoded transparent gif:

background-image: url('data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICR‌​AEAOw==')

This has its own pros/cons, but can be useful. Also:

background-color: rgba(0,0,0,0)

I've used this one more recently


@tw16's comment mentioning invisible got me thinking about opacity.

Combining IE's filter:alpha(opacity=0) with background-color:#fff (or any color) appears to be a good solution for this. Tested and works in IE 7-9 (6 isn't applying the opacity filter for some reason but I'm not required to support 6 so this will work)

The 1x1 image solution is globally effect so I'm going to give the check to him.

Thanks for the answers.


I had the same problem. My working solution was to add a border to the appropriate anchor. Like the following example. One advantage is, you need no extra image.

a { border-right: 1px solid transparent }