?
Solved

Style to set color for table row

Posted on 2008-06-09
6
Medium Priority
?
369 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:Terry Woods
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:tomaugerdotcom
ID: 21747120
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>
0
 
LVL 14

Expert Comment

by:tomaugerdotcom
ID: 21747128
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>
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 21747160
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?
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 42

Expert Comment

by:David S.
ID: 21747182
You could apply a class to each row instead of each cell.
0
 
LVL 14

Accepted Solution

by:
tomaugerdotcom earned 1200 total points
ID: 21747223
I'm going to simplify the code a bit to save time
<table id="myTable">
 <tr class="redRow">
   <td>Red stuff</td>
 </tr>
 <tr>
   <td>This stuff is not red</td>
  </tr>
</table>

the stylesheet for this would be
table#myTable tr.redRow td { color:red; etc...}
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 21747269
Just what I needed - thanks so much for the quick response!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question