Mystery of the disappearing hover state

I stumbled across a CSS bug in a project last week and along with my fellow CSS-ing colleague was completely taken aback that we hadn’t run into it or been aware of it before.

In short, when you clicked a text link and returned to the page afterwards the hover state on the link you clicked had disappeared/stopped working.

Some digging on the trusty internet eventually turned up a few posts like this one outlining how to get around such an issue you need to order your link’s pseudo classes in a particular order like so:

a:link, a:visited { /* style goes here */}
a:hover { /* style goes here */}
a:active { /* style goes here */}

The mnemonic LVHA is how I’m ingraining it into my memory. Is this what I get for not reading the W3C spec from cover to cover? :)

This entry was posted in CSS and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>