Log in

View Full Version : colored links inheriting property values



james438
12-13-2007, 01:17 AM
How can I get the links to not inherit the properties of the body. For some reason the top link behaves correctly, but with the wrong color while the second one has the right color, but now the javascript does not work.

I am rusty and am not sure what I am doing wrong.

Thanks


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<style type="text/css">
body {
background-color: #000000;
}

a:link {
color: #000000;
}
a:visited {
color: #666666;
}

.style9 {
color: #9900CC;
visited: #9900CC;
}
-->
</style></head>
<script src="http://i.thottbot.com/power.js"></script>
<body>
<div align="center"><a href='http://thottbot.com/i30247'>Leggings of the Vanqud Hero x2</a><br>
<a href='http://thottbot.com/i30090'><span class="style9">World Breaker</span></a><br>
</div>
</body>
</html>

james438
12-13-2007, 02:59 AM
I fixed it. I added
a.style9 {
color: #9900CC;
visited: #9900CC;
}
as opposed to
style9 {
color: #9900CC;
visited: #9900CC;
}

boogyman
12-13-2007, 02:04 PM
I fixed it. I added
a.style9 {
color: #9900CC;
visited: #9900CC;
}
}

I have never seen that work, and I dont believe it should on standards compliant browsers. You would need to declare each psuedo selector explicitly, however you can group them together somewhat like.



a.style9:link, a.style9:visited {
color: #9900cc;
}

james438
12-13-2007, 02:21 PM
I see the error now. I am now going to use:


a.style9:link {color: #9900cc;}
a.style9:visited {color: #9900cc;}

boogyman
12-13-2007, 02:28 PM
a.style9:link {color: #9900cc;}
a.style9:visited {color: #9900cc;}

thats correct, the way you have it there does them separately, however you were declaring yours in 1 instance, so thats why I modeled mine the way I did. But if the person is going to have them the same initially, it's usually a good bet they will always want it that way.

james438
12-13-2007, 02:37 PM
Thanks for the tip. It all looked like it was working at first glance, but after a closer look I saw that my "fixed" code still was not working quite right.