Forum Moderators: not2easy

Message Too Old, No Replies

can I set a link color inline?

         

annej

6:25 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to make just one link a different color because of a dark background. How would you do it?

SuzyUK

6:36 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes Anne, you can set it inline, but you would not be able to control the pseudo classes
:link, :hover, :visited.. etc..

<a href="#" style="color: red; background: #ff0;">this will always be red on yellow</a>

one way to do it if you want pseudo class changes would be to add a special class name instead

<a href="#" class="highlite">your special link</a>

CSS:
a.highlite:link {}
a.highlite:visited {}
a.highlite:hover {}

Suzy

[edited by: SuzyUK at 6:40 pm (utc) on Feb. 15, 2006]

Fotiman

6:38 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would do it by targeting the link within the "dark" ancestor element. For example:

<div class="thisisdark">
<a href="">Change Me</a>
</div>

Then the CSS:

div.thisisdark
{
background-color: black;
}
div.thisisdark a
{
color: white;
}

Fotiman

6:39 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Note also that with my suggestion you could also specify the pseudo classes.

annej

7:08 pm on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the suggestions everyone. :)