Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How in the name of CSS do I create two different styles of a:link on the same page ?

How in the name of CSS do I create two different styles of a:link on the same page ?
Thread Tools
Senior User
Join Date: Sep 2000
Location: Noo Yawk
Status: Offline
Reply With Quote
Jul 13, 2002, 09:21 PM
 
How in the name of CSS do I create two different styles of a:link, a:visited, a:active, a:hover.... on the same page, using styles and stylesheets ?

In other words,

I have a linked site-wide stylesheet that represents links in sans-serif families, red, bold no underline, and changes to blue with underline on hover, etc etc.

However for the main navigation links on some pages I'd like to switch from slow-loading elaborate js-rollovers to more simple css styles using backgrounds/colors with the tags a:active a:link, a:hover, a visited.

How do I get the same <a> link family tags to mean different things on the same page?

I've attempted to make them local to the TD that the NAV resides in but to no avail.

An example page that suffers from this syndrome is:

<a href="http://www.h2omen.com/htmlfiles/dastories.html" target="_blank">http://www.h2omen.com/htmlfiles/dastories.html</a>

     
Mac Elite
Join Date: Mar 2001
Location: somewhere in ohio
Status: Offline
Reply With Quote
Jul 13, 2002, 09:38 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">
A:link {/*normal links in the text*/
color: blue;
text-decoration : none;
background: #FFFFFF;}
A:visited {
color: #FF0000;
text-decoration : none;
background: #FFFFFF;}
A:hover {
color: #999999;
text-decoration : underline;
background: #FFFFFF;}

/*now follow the section links in the navigation bar on the left side*/
A.nav:link {
color: #FFFFFF;
text-decoration : none;
font-weight: 600;
font-size:14px;
background: transparent;}
A.nav:visited {
color: #FF8C00;
text-decoration : none;
font-weight: 600;
font-size:14px;
background: transparent;}
A.nav:hover {
color: #7FFFD4;
text-decoration : none;
font-weight: 600;
font-size:14px;
background: transparent;}
A.navtot {/*the style for the actual page*/
color: #CDCDCD;
text-decoration: none;
font-weight: 600;
font-size: 14px;
background: transparent;} </font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">That should help
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jul 14, 2002, 10:44 AM
 
Make them local to the TD, huh?

In that case, I'd suggest a different approach from the one Kaya mentions.

Instead of giving all the links in the TD a class, give the TD itself an ID attribute. Let's sey you call it "nav". Make your links as normal.

Then, in the stylesheet, you'll have two styles for the links. Most of the links will look like:

a:link
a:visited
a:hover
a:active

However, the ones in the TD will be styled under:

#nav a:link
#nav a:visited
#nav a:hover
#nav a:active

All CSS-supporting browsers should be able to work with this technique (NS4 doesn't do a:hover, but that can't be helped, and it will get the other link types right). It also lets you just add only one ID attribute to your HTML, rather than a while bunch of class attributes, which will save you a little bandwidth in the long run.

This technique will parse a bit slower under most browsers (the age-old tradeoff of size for speed). However, unless your page is a couple of megs in size, you shouldn't even be able to notice the speed difference, which will be more than offset by the faster download times.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:37 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2