View Full Version : Combining Link Attributes

08-02-2010, 12:47 AM
Hi all..

this is probably an easy one - =)

I have a class I'll call
I want it to look the same in all states - whether linked, or hovered or what have you....so instead of writing all 4 elements of linkage, can I combine it all?

thanks in advance!


08-02-2010, 01:51 AM
Defining only the color for the font, you will probably end up with different colors for, if not all other attributes, at least a:visted. Most web browsers will use their default color for visited links (usually purple) if one hasn't been defined. Four lines would be a lot if you planned on using style="" every time you wanted to make the text blue, but that's why we have stylesheets. Specifying the color for links as well as font will also be sure that the color you want overrides your default attributes, so if you already have a:hover{color: #FFFFFF} you won't have white text when you hover over the link where it's supposed to be blue.

.blue {color: #FF0000;}
.blue a:link{color: #FF0000;}
.blue a:visited{color: #FF0000;}
.blue a:active{color: #FF0000;}
.blue a:hover{color: #FF0000;}

08-02-2010, 06:06 AM
You can also combine the rules on single line like that:

.blue, .blue a:link, .blue a:visited, .blue a:active, .blue a:hover{color: #FF0000;}