Link to home
Create AccountLog in
Avatar of Terry Woods
Terry WoodsFlag for New Zealand

asked on

Style to set color for table row

I have the following style set up to make the font color red for the row, but it's not changing the color - any ideas why not?
<tr style="color:Red; " onMouseOver="style.background='#ffff77';" onMouseOut="style.background='';">
  <td valign="top">Joe Bloggs</td>
...
</tr>

Open in new window

Avatar of tomaugerdotcom
tomaugerdotcom
Flag of Canada image

since TR cannot contain text, you can't use the color style there. try these things:

<tr onMouseOver etc....><td style="vertical-align:top; color: red;">Joe Bloggs</td>...</tr>
or, better, stay away from inline styles altogether:

<table id="myTable">
  <tr onMouseOver.....>
    <td>Joe Bloggs</td>
.....
  </tr>
....
</table>

<style type="text/css">
    table#myTable td { vertical-align:top; color:red; }
</style>
Avatar of Terry Woods

ASKER

There are more cells in the table row, and I want the whole row to have red text with minimal style code. But not every row is to have red text. If I use a style sheet, will I need to (say) specify a css class for each cell in the rows that need red text?
You could apply a class to each row instead of each cell.
ASKER CERTIFIED SOLUTION
Avatar of tomaugerdotcom
tomaugerdotcom
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Just what I needed - thanks so much for the quick response!