...

View Full Version : highlighting table rows



rudi
11-12-2002, 03:01 PM
How can I easily highlight an entire row in
a table (by changing the background color
or bold-facing the text) ?

Thanks a million !
rudi

Roy Sinclair
11-12-2002, 04:02 PM
By putting a style on the <tr> tag for the row.

<tr style="background-color: #0000FF; color: white;">...</tr>

BrainJar
11-12-2002, 04:10 PM
You can set up CSS class for highlighting:

tr.highlight {
background-color: #000080;
color: #ffffff;
}

And add mouse events to each row:

<tr onmouseover="this.className='highlight';"
onmouseout="this.className='';">

As long as your TD elements don't have styles set for background or foreground color they will inherit those properties from the TR element.

rudi
11-12-2002, 05:25 PM
Thanks a lot for your help guys !!!

Cheers !
rudi :)

Bosko
11-12-2002, 06:23 PM
tr:hover{
background-color:highlight
}

Would also do the trick,and its much easier.

Roy Sinclair
11-12-2002, 08:49 PM
Originally posted by Bosko
tr:hover{
background-color:highlight
}

Would also do the trick,and its much easier.

As long as your audience is using a Gecko based browser (like Mozilla), of course the IE users wouldn't see any highlights. Unfortunately, while this is the right way to do it you've got to do it that hard way for now if your audience isn't up to date.

Bosko
11-12-2002, 09:38 PM
That will also work in Konqueror and Opera...

beetle
11-12-2002, 10:49 PM
Originally posted by Bosko
That will also work in Konqueror and Opera... Mozilla + Netscape + Konqueror + Opera =~ 10%-12% of users

Too bad, since the :hover pseudo-class is SO much easier. Better use the javascript method if you want the bulk of your users to see the effect.

Note: you could do both by using an HTC for the javascript rollover and the :hover pseudo-class. In both instances the browser would only use the one it supports.

Bosko
11-13-2002, 10:59 AM
Mozilla/Netscape + Konqueror + Opera =~ ?% of users

It all depends on the site,maybe its 10% for microsoft.com,but I have seen sites where the majority of the users uses Mozilla/Netscape.

Well,thats the beaty of W3C standards,it allows you to create cool effects very easily :)

beetle
11-13-2002, 02:40 PM
Well Bosko, what you say can certainly be true (about the percentage) but I think it's non-controversial to say that that is the exception rather than the rule.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum