getting columns to change color on hover

R

Rahul

Is there a way to get a column to change emphasis color using css? I could
successfully do this for rows but it does not seem to work for columns.

table col:hover{
background: #d0dafd;
color: #339;
}
 
J

Jonathan N. Little

Rahul said:
Is there a way to get a column to change emphasis color using css? I could
successfully do this for rows but it does not seem to work for columns.

table col:hover{
background: #d0dafd;
color: #339;
}
No, because TDs are not descendants of COL elements in DOM. What you
wish requires JavaScript.
 
D

dorayme

"Jonathan N. Little said:
No, because TDs are not descendants of COL elements in DOM. What you
wish requires JavaScript.

I think you are right.

Mind you, OP can get a col to change colour by hovering on a table
without js, but this is not quite what he wants.
 
R

Rahul

Mind you, OP can get a col to change colour by hovering on a table
without js, but this is not quite what he wants.

Actually, that was what I was thinking about. Maybe my spec wasn't clear or
the finer distinctions of html are lost on me! :)

Again,

I can get a row to change color when I hover. Now if I could get a column
to do that too it would be neat. Sort of the crosshair effect so that both
the horizontal and vertical associations are clear.

From what "dorayme" writes is that possible in html? Or is javascript my
only option?
 
J

Jonathan N. Little

Rahul said:
Actually, that was what I was thinking about. Maybe my spec wasn't clear or
the finer distinctions of html are lost on me! :)

Again,

I can get a row to change color when I hover. Now if I could get a column
to do that too it would be neat. Sort of the crosshair effect so that both
the horizontal and vertical associations are clear.

From what "dorayme" writes is that possible in html? Or is javascript my
only option?

No, as I said it would require JavaScript. COL is one of those oddball
legacy "presentational" elements. It does not reveal itself in the DOM
so CSS will not work on it. Use Web Developer's bar or some DOM
inspector and your will see for yourself


<html>
<body>

<table width="100%" border="1">
<col align="left"></col>
<col align="left"></col>
<col align="right"></col>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
<tr>
<td>2489604</td>
<td>My first CSS</td>
<td>$47</td>
</tr>
</table>

</body>
</html>


COL will be a child of TABLE but *not* a child of TBODY where all the
TDs are that you want to change background.

TABLE > COL

TABLE > TBODY > TR > TD
 
D

dorayme

"Jonathan N. Little said:
No, as I said it would require JavaScript.

OP can get a col to change colour by hovering on a table
without js, but this is not quite what he wants, he wants to be able to
hover on the col itself.
 
R

Rahul

No, as I said it would require JavaScript. COL is one of those oddball
legacy "presentational" elements. It does not reveal itself in the DOM
so CSS will not work on it. Use Web Developer's bar or some DOM
inspector and your will see for yourself

Thanks Jonathan! THe "Developers Toolbar" is awesome! I had no idea this
existed. It makes examining how stuff works so easy.

Thanks again!
 
J

Jonathan N. Little

Rahul said:
Thanks Jonathan! THe "Developers Toolbar" is awesome! I had no idea this
existed. It makes examining how stuff works so easy.

Great tool, not if Chris would just get it updated for Firefox 3.5.x
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top