[thelist] Changing link colors

Aylard JA (James) jaylard at equilon.com
Wed Nov 1 10:54:54 CST 2000


Gary,

> How does one change link, A:link{ , colors on the same page, for 
> instance one color for a white background and another for a colored 
> background.

	A couple of ways: you can assign a class name to each link,
depending on which background color is behind it. For instance:

<a class="BgBlack" href="foo.htm">Foo</a>
...
<a class="BgBlue" href="bar.htm">Bar</a>

	and in your style sheet:

a.BgBlack:link { color: #ffffff ; }
a.BgWhite:link { color: #000000 ; }

	Or, probably an easier way: assuming that your background color is
set on a particular <table>, <td>, or <div>, you could assign an id to each
container as required:

<div id="DivBlack">
   <a href="foo.htm">Foo</a>
</div>
<div id="DivWhite">
   <a href="bar.htm">Bar</a>
</div>

	and in your style sheet:

#DivBlack { background-color: #000000 ; }
#DivBlack a:link { color: #ffffff ; }
#DivWhite { background-color: #ffffff ; }
#DivWhite a:link { color: #000000 ; }

	You could also use classes for your divs, tables, tds, etc.

hth,
James Aylard




More information about the thelist mailing list