/    Sign up×
Community /Pin to ProfileBookmark

Global CSS declaration for "a" (i. e. "a href") tag

I have style definitions that look like this:

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

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!

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@KDLAAug 20.2007 — I think you answered your own question:
<i>
</i>a {text-decoration: none;}
a:hover {text-decoration: underline;}


KDLA
Copy linkTweet thisAlerts:
@knkkauthorAug 20.2007 — Okay, this works:

[CODE]
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*/
[/CODE]


That is, something like:
[CODE]
<DIV CLASS="v10w"><A HREF="whatever">some text</A></DIV>
[/CODE]


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!
Copy linkTweet thisAlerts:
@KDLAAug 20.2007 — 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
Copy linkTweet thisAlerts:
@knkkauthorAug 21.2007 — Thanks, KDLA - yes, I am indeed working on it.
×

Success!

Help @knkk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...