Click to See Complete Forum and Search --> : Global CSS declaration for "a" (i. e. "a href") tag


knkk
08-20-2007, 01:19 PM
I have style definitions that look like this:


.a10b,
.a10b a:link,
.a10b a:visited,
.a10b a:hover
{
font: 10px Arial;
color: #000000;
text-decoration: none;
}
.a10b a:hover {text-decoration: underline}


I have 20 text styles, and for all of them I declare like this, resulting in a lengthy style sheet.

a:link and a:visited should always be {text-decoration: none} for me, and a:hover always {text-decoration: underline}.

If I could declare these in just one place, valid for all styles, I would save huge bytes. Is that possible?

Thank you very much for your time!

KDLA
08-20-2007, 02:20 PM
I think you answered your own question:

a {text-decoration: none;}
a:hover {text-decoration: underline;}


KDLA

knkk
08-20-2007, 02:31 PM
Okay, this works:


a {text-decoration: none;}
a:hover {text-decoration: underline;}

.v10w,
.v10w a
{
font-family: Verdana;
font-size: 10px;
color: #FFFFFF;
}
/*several other styles like this*/


That is, something like:

<DIV CLASS="v10w"><A HREF="whatever">some text</A></DIV>


now renders the link white (without the "v10w a" there, it would be blue in color), without underline, and with an underline only on hover.

It is a indeed huge reduction in code :). Now if only I could get rid of the ".v10w a" too. But I am pretty pleased with myself. Thanks a bunch, KDLA!

KDLA
08-20-2007, 02:40 PM
You may want to go through your code and condense it into a global style as much as possible. Having as many classes as you mention creates bloated coding. ;)

KDLA

knkk
08-21-2007, 12:49 AM
Thanks, KDLA - yes, I am indeed working on it.