Posts filed under ‘Uncategorized’

CSS: IE6 compatibility for <a> tags with no href attribute

Since I still need to worry about compatibility with older browsers (especially IE) on most of my web applications, I try to make sure all of the CSS I use works under IE 6 and up, as well as FireFox and Chrome. I ran into this interesting issue last week (this does seem to be documented elsewhere, so maybe I am just the last to have encountered it). Should you have an anchor tag with no href attribute, IE will not apply any matching a:hover styles. (Althought, IE7+ and Mozilla browsers do). The reason for this is somewhat legit – IE considers an <a> tag without an “href” attribute to be a “destination” anchor tag – that is, an anchor which would be used for intra-page jumping (as in, <a name=’myBookmark’>). And IE only applies :hover styling on “source” anchors – that is, anchors which actually link to something. In my unfortunate situation, I had an anchor tag which was used exclusively to launch some JavaScript. The simple solution – to add an href=”#” attribute.

November 22, 2009 at 4:32 pm


Ed Schembor’s Blog

Adventure's of an application developer, living in the world of corporate IT.

Feeds

Categories