Style to set color for table row

Posted on 2008-06-09
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>

Open in new window

Question by:Terry Woods
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
LVL 14

Expert Comment

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>
LVL 14

Expert Comment

ID: 21747128
or, better, stay away from inline styles altogether:

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

<style type="text/css">
    table#myTable td { vertical-align:top; color:red; }
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?
Technology Partners: 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!

LVL 42

Expert Comment

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

Accepted Solution

tomaugerdotcom earned 300 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>
   <td>This stuff is not red</td>

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

Author Comment

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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

696 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