Switching Link Colors..

liunx

Guest
Hey.. I was wondering after i've already set the link color to one color can I change it and have the old settings affect the old part and after the new tag change the color?<br />
<br />
This is what's going on...<br />
<br />
I have a site and I need the link color of some things to be black. Later I want to change them back to blue because there is a black background and I cant see the text.. Can anyone help??<br />
<br />
Thanks!<!--content-->Yep, use CSS......<br />
and put a class in yout link.<br />
Info SIte:<br />
<!-- m --><a class="postlink" href="http://www.w3schools.com/css/default.asp">http://www.w3schools.com/css/default.asp</a><!-- m --><!--content-->you can assign page level styles to override your linked styles. Inline styles woul even override your pqage level styles.<br />
<br />
Heres an example of how to use classes instead of all that other stuff. Just make sure to name a class in the href tag;<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br />
<br />
<html><br />
<head><br />
<title>Untitled</title><br />
<STYLE TYPE="text/css"><br />
a.dog:link { color: blue; text-decoration: none }<br />
a.dog:active { color: red; text-decoration: none }<br />
a.dog:visited { color: blue; text-decoration: none }<br />
a.dog:hover { color: green; text-decoration: underline }<br />
<br />
a.tree:link { color: green; text-decoration: none }<br />
a.tree:active { color: yellow; text-decoration: none }<br />
a.tree:visited { color: red; text-decoration: none }<br />
a.tree:hover { color: orange; text-decoration: underline }<br />
</STYLE> <br />
</head><br />
<body><br />
<a href=http://www.htmlforums.com/archive/index.php/"#" class=tree>tree</a><br><br />
<a href=http://www.htmlforums.com/archive/index.php/"#" class=dog>dog</a><br />
</body><br />
</html><!--content-->What doc posted is fine for most situations of normal hover, but The way I read this you want to do the change on the link unrelated to the hover as part of a background color change in that case:<br />
<br />
<STYLE TYPE="text/css"> <br />
.dog a { color: black; } <br />
.tree a { color: blue; } <br />
</STYLE> <br />
<br />
I use doc's dog and tree they seemed to go together. <br />
:eek: <br />
<br />
The links get the class applied by inheriting from a span or div with and id:<br />
<span id="stuff" class="dog"><br />
<a href=http://www.htmlforums.com/archive/index.php/"???">one </a><br />
<a href=http://www.htmlforums.com/archive/index.php/"???">two </a><br />
<a href=http://www.htmlforums.com/archive/index.php/"???">three </a><br />
<a href=http://www.htmlforums.com/archive/index.php/"???">four </a><br />
</span><br />
<br />
Now when you are ready to do the switch, in the script you just use: document.getElementById('stuff').className='tree'<br />
<br />
none of this will work in Netscrap 4 of course to change the link color for NS4 takes major scripting.<!--content-->Ok, Thanks!<br />
<br />
I can always count on you guys! hehe<br />
<br />
I'm gonna learn more about CSS so I can figure out what you're talking about :D and integrate it into my site..<!--content-->To learn CSS:<br />
<br />
<!-- m --><a class="postlink" href="http://www.pageresource.com/dhtml/indexcss.htm">http://www.pageresource.com/dhtml/indexcss.htm</a><!-- m --><!--content-->k thanks I got it to work!! YAY!!<!--content-->
 
Back
Top