Welcome to WebmasterWorld Guest from 54.167.85.221

Forum Moderators: not2easy

Message Too Old, No Replies

Distinguishing Link code

Assigning an style to a link but using a different style while on page.

     

entreprenur724

6:32 am on Dec 21, 2011 (gmt 0)



I set up a body-id to each page to make it simple to link to pages from the nav menu. The trouble is in changing the styles while visiting said page.

For example. I set up the default font color to white for all links on the nav bar, with a hover and active of blue with the following code:

#nav li a:link, #nav li a:visited {
color: white;
}

#nav li a:hover, #nav li a:active {
text-decoration: none;
color: blue;
}

Now say I want to change the link color to green after you click on one of the links and visit the page. So while on any given page, the link color for that page will be green.

How do I specify a different font color in this scenario?

Thanks!

penders

9:10 am on Dec 21, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



You have already applied a unique id to the body of each page. You also need to apply a unique id to each of your links in your nav - since you need to target each link individually in order to style it.

Then you need to provide a style rule for each body/link combo... so that the link-to-page-N when actually on page-N is green.

#pageN #nav li a#linkpageN { 
color: green;
}


... repeat for each of your links.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month