Forum Moderators: not2easy
I'm trying to find a more streamlined approach to redefining a tags. Take the following example:
<div class="qlinks">
<a class="qlinks" href="#">
<a class="qlinks" href="#">
<a class="qlinks" href="#">
</div>
This is how I currently have it setup. Here is the associated styling:
.qlinks {
text-align:center;
}
a.qlinks, a.qlinks:visited, a.qlinks:active, a.qlinks:link {
font: bold 12px/1.5em Verdana;
color: #000;
text-decoration:underline;
}
a.qlinks:hover {
font: bold 12px/1.5em Verdana;
color: #959595;
text-decoration:underline;
}
I thought there was a way to do something like this instead of what I have above in order to condense the styling down as much as possible, however it doesn't seem to be working:
.qlinks a, a:active, a:visited, a:active, a:link {
font: bold 12px/1.5em Verdana;
color: #000;
text-decoration:underline;
}
.qlinks a:hover {
font: bold 12px/1.5em Verdana;
color: #959595;
text-decoration:underline;
}
And then the resulting HTML would look something like this (notice the class="qlinks" is not present on each a property, but it should still inherit the styling:
<div class="qlinks">
<a href="#">
<a href="#">
<a href="#">
</div>
Any idea where I'm going wrong, or a better approach perhaps? Sometimes on my sites it is necessary to have 2 or more different font stylings. Not ideal I know, but that's how I'm told to do it.
.qlinks a, .qlinks a:visited, .qlinks a:active, .qlinks a:link { ...
I'm not sure why the CSS you have doesn't work; it should apply those styles to every a:visited, a:active, and a:link (not just those under the qlinks div). My guess would be that you have a rule for anchor tags with more specificity or higher on the cascade that supercedes this rule. (Rules with more selectors have a higher specificity, and take precedence over those that have fewer. Rules also "cascade" in the order of: those defined inline take precedence over those in the head, which take precedence over those loaded with a <link>)