Home » Programming / Coding

Css Hover Not Working in FireFox

21 February 2008 295 views No Comment

You may have seen this weired problem; css hover for font not working in FireFox. However it works fine in IE.

I will give you an example. Lets say this is my document code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head>
<style type=”text/css”>
.default { font-size: 12px; font-family: Verdana, Arial; color: #656565; }
a.default:link { text-decoration: none; color: #656565; }
a.default:hover { text-decoration: none; color: #017812; }
a.default:active { text-decoration: none; color: #656565; }
a.default:visited { text-decoration: none; color: #656565; }
</style>
</head>
<body>
<div class=”default”>
<a href=”index.html” class=”default”>products</a>
</div>
</body>
</html>

Funny enough this doesn’t work with Firefox.

Solution?
Make sure to put the hover style comes after the active and visited style.
So the refined code that works is:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head>
<style type=”text/css”>
.default { font-size: 12px; font-family: Verdana, Arial; color: #656565; }
a.default:link { text-decoration: none; color: #656565; }
a.default:active { text-decoration: none; color: #656565; }
a.default:visited { text-decoration: none; color: #656565; }
a.default:hover { text-decoration: none; color: #017812; }
</style>
</head>
<body>
<div class=”default”>
<a href=”index.html” class=”default”>products</a>
</div>
</body>
</html>

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

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

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.