Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to change the colour of SOME links, not ALL.

Status
Not open for further replies.

LisaPapakis

Technical User
Jun 26, 2008
3
GR
Hi everyone. I'm using Dreamweaver 8. I set up my css style in 'page properties'. But now I want to change the colour of some of my links on the page, (from white to grey) but when I do, the link colour defaults to the one defined in my css (white). I have attached new style sheets, but when creating them they don't have a:link ids, so I have copied a:link ids from my main style sheet to my new one, and then changed the a:link to grey - whereupon all the links turn grey! Am tearing my hair out! Please help! Lisa.
 
Use a different class for the grey links and define the class in your style sheet. e.g.
Code:
...
 a.nav2:link {color: #333333}
...
<a href="default2.asp" target="_blank" [COLOR=red]class="nav2"[/color]>[COLOR=gray]This is a different color link[/color]</a></
Use whatever class name is appropriate for your needs. (I do not recommend using the color name in the class as you may change your mind in the future).

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Thank you for responding. Im still having no success. When I use your code, my links still appear one colour. Here is my code:

<body>
<p><a href="A1VA_Websites2.html" class="greenlink">linky link link</a></p>
<p><a href="default2.asp" target="_blank" class="redlink">linky link link too</a></
</body>

And this is what my css looks like:

greenlink css
.greenlink {
}
a:link {
color: #00CC00;
}
a:visited {
color: #00CC00;
}
a:hover {
color: #FFFF00;
}

redlink css

.redlink {
color: #FF0000;
}
a:link {
color: #FF0000;
}
a:visited {
color: #FF0000;
}
a:hover {
color: #FFFF00;

Both text links are red/ yellow/ red, despite the first one saying it's 'greenlink' in the property inspector. Many thanks Lisa
 
Did you even read what he posted specifically the example?:
Code:
 a.nav2:link {color: #333333}

So using your green link class it would have to be:

Code:
 a.green:link {color: #333333}

By the way, you need to actually specify the other states of the link as well otherwise they'll default to your other css.

a.green:visited
a.green:active
a.green:hover

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
You specified a class selector in your stylesheet that has no properties in it.

As Vacunita pointed out you need to specify the class for each state. In your example, it should be:
Code:
[s].greenlink {
}[/s]
a[gray].greenlink[/gray]:link {
    color: #00CC00;
}
a[gray].greenlink[/gray]:visited {
    color: #00CC00;
}
a[gray].greenlink[/gray]:hover {
    color: #FFFF00;
}

[s].redlink {
    color: #FF0000;
}[/s]
a[gray].redlink[/gray]:link {
    color: #FF0000;
}
a[gray].redlink[/gray]:visited {
    color: #FF0000;
}
a[gray].redlink[/gray]:hover {
    color: #FFFF00;
(And you really, really don't want to call them redlink and greenlink.)

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Thank you for your responses, I have now solved the problem. Thank you for your patience, traingamer. And to Vacunita, yes I read carefully what traingamer said, and I tried to do it for an hour. I am not a stupid person but I have had no training in HTML or CSS, and it was difficult for me. I wonder if you would be so rude had you just met me in person.
 
I wasn't trying to be rude, just asking a question. you clearly had not read it carefully, or you would have been able to realize where exactly traingamer put the class name.

It was just a simple matter of following the example, not trying to create it yourself.

I realize you may not be an expert in html or CSS, but I'm sure you could follow an example.

Anyway, I apologize if I offended you, it just seemed to me the example was more than self explanatory. And we do get people here that expect everything handed to them on a silver platter.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top