is this possible w/ CSS? changing color of a link inside cell when i mouseover cell

Chau

Senior member
May 23, 2001
712
4
71
currently i have links defined as a certain color and changes to a certain color when i hover over them.. i have a table which has these links inside the cells and when i hover over the cell, the background of the cell changes color but the link wont change color until i hover over the link.. is there anyway so that when i hover over the cell i can make the link change color too?

the problem is i have some padding for the cells, so once i go inside the cell but dont hover exactly over the link, the background will change but the link won't until i hover over it

thanks
 

pmoa

Platinum Member
Dec 24, 2001
2,623
3
81
no i dont think it can be done through CSS. the only way that could happen is if the cell had a gif with the same color BG as the cell and make the gif a rollover. im guessing you are trying to avoid this.
 

grubbster

Junior Member
May 14, 2004
9
0
0
Just use javascript, its pretty easy. I'm sure if u search the net you will find 100's of examples of what u are looking for
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
can be done with a javascript that changes the css script for the cell
 

jgbishop

Senior member
May 29, 2003
521
0
0
I believe that this can indeed be done with CSS (no javascript). Just use a chain of selectors to define your rules:

td a { color: somecolorhere; }

or something like

td a:hover { color: somecolorhere; }

Then, your normal links will appear as one color, while links in a table cell (the TD tag) will appear as another color.
 

JW310

Golden Member
Oct 30, 1999
1,582
0
0
Originally posted by: jgbishop
I believe that this can indeed be done with CSS (no javascript). Just use a chain of selectors to define your rules:

td a { color: somecolorhere; }

or something like

td a:hover { color: somecolorhere; }

Then, your normal links will appear as one color, while links in a table cell (the TD tag) will appear as another color.

[edit]the below works for hovering over a link, not sure about hovering over a cell :-/ [/edit]

Yep, that's how to do it. Here's an excerpt from a CSS file I wrote for a site I'm designing:
 

jgbishop

Senior member
May 29, 2003
521
0
0
What I suggested (I think) only affects links in cells - not the cells themself. Either way probably works as well as the other. But you don't want to get a case of "classitis" (using too many classes) when a simple rule like the ones I offered could clean up your code. The smaller your markup, the less bandwidth is eaten up. :)
 

dukdukgoos

Golden Member
Dec 1, 1999
1,319
0
76
td:hover {background-color: #something}

won't work in IE, but works in better browsers like Mozilla, Firebird, Opera, Safari, etc.