Solution: Css Hover Not Working in FireFox

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>

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: WebCosmo
Posted on: 2/21/2008 at 3:43 PM
Categories: Programming / Coding
E-mail |  Stumble it! |  Propeller it! |  Digg it! |  del.icio.us |  Technorati
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Related posts

Comments

Yiwu China cn

Friday, February 22, 2008 1:51 AM

Yiwu China

Ya,it seems that CSS still had some problem with Firefox

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Wednesday, December 03, 2008 10:54 AM