Forum Moderators: not2easy

Message Too Old, No Replies

[FireFox] A:visited in TD class does not override A:visited in main

         

toptalent

9:21 am on Mar 6, 2007 (gmt 0)

10+ Year Member



I've having an issue with the a:visited propery in Firefox.

I have a template based website that sets the following propery in its main css file default.css:


A:link {
text-decoration: none;
color: #003366;
}

A:visited {
text-decoration: none;
color: #003366;
}

A:hover {
text-decoration: underline;
color: #ff0000;
}

A:active {
text-decoration: none;
color: #003366;
}

Now I have this specific module (forum) that uses its own css ettings in module.css. In this module, I need to alter the a: properties on a paticular cell in a table via a CSS class like this:

<td class = "cellclass">

Here's the "cellclass" setting in my module.css:


.afforumrow a:link {text-decoration:none; color:#000000;}
.afforumrow a:visited {text-decoration:none; color:#000000;}
.afforumrow a:hover {text-decoration:underline; color:#000000;}
.afforumrow a:active {text-decoration:none; color:#000000;}

Now everthing works fine in IE. But in FireFox the a:visited propery set by my "cellclass" does not override the a:visited propery set in the main CSS file. When the link has not been clicked, it does display "#000000"; however once it's clicked, it dispalys "#003366" instead of "#000000" as it's instructed to in module.css.

I have tried adding "!important" in the cellclass but it still doesn't work.

Your help would be appreciated!

toptalent

9:25 am on Mar 6, 2007 (gmt 0)

10+ Year Member



Correction: I made a typo in the original post.


.afforumrow a:link {text-decoration:none; color:#000000;}
.afforumrow a:visited {text-decoration:none; color:#000000;}
.afforumrow a:hover {text-decoration:underline; color:#000000;}
.afforumrow a:active {text-decoration:none; color:#000000;}

is actually


.cellclass a:link {text-decoration:none; color:#000000;}
.cellclass a:visited {text-decoration:none; color:#000000;}
.cellclass a:hover {text-decoration:underline; color:#000000;}
.cellclass a:active {text-decoration:none; color:#000000;}

Thanks.

SilverLining

1:54 pm on Mar 6, 2007 (gmt 0)

10+ Year Member



Try adding
td.
before each cellclass in your CSS:


td.cellclass a:link {text-decoration:none; color:#000000;}
td.cellclass a:visited {text-decoration:none; color:#000000;}
td.cellclass a:hover {text-decoration:underline; color:#000000;}
td.cellclass a:active {text-decoration:none; color:#000000;}

Fotiman

3:20 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Both sets of rules that you listed have the same specificity, therefore, whichever one is defined last in the stylesheet will win. You could fix that by adding the td to the specifier as was mentioned.

SilverLining

7:10 pm on Mar 6, 2007 (gmt 0)

10+ Year Member



Thank you for your explanation, Fotiman. I'm not great on the explaining side of things, as you can tell.

toptalent

10:08 pm on Mar 6, 2007 (gmt 0)

10+ Year Member



Thanks for your help. But unfortunately adding td. does not fix the problem. It still fails to override the global a: under Firefox.

SilverLining

10:23 am on Mar 7, 2007 (gmt 0)

10+ Year Member



Does the overriding CSS appear after the global link styles within the CSS file? Because of the way Cascading style sheets work, the last one mentioned will override the first.

If you are using a template and calling different CSS files, make sure the one containing the td.cellclass styles is listed last.

Read more about Cascading Order [blooberry.com] and Inheritance.

Fotiman

3:34 pm on Mar 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also, you might try installing the FireBug extension for firefox. This extension will let you "inspect" an element on your page and it will tell you exactly where it's getting it's style from (what rules in the CSS are being applied and/or overwritten).