milk4cats
02-20-2003, 08:32 PM
I am doing a site that uses css classes in tables, but I don't know how to make either the td or tr have a background color. I want the same effect as if you used the code ...
<tr bgcolor="#3399ff">
<td>
text here
</td>
</tr>
<tr bgcolor="#3399ff">
<td>
text here
</td>
</tr>
because I have this repeated a lot I wanted it in a css class, but I can't find anything on td/tr bg, so how can it be done?
I'm not too creative with names so I chose "colour", lol :stickout:
<style type="text/css">
tr.colour
{
background-color:#3399ff;
}
</style>
<table>
<tr class="colour">
<td>
text here
</td>
</tr>
<tr class="colour">
<td>
text here
</td>
</tr>
</table>
milk4cats
02-22-2003, 12:35 AM
It works, but is there a way to do it without tr having it's own class? Like the tr being part of the class "rightside"?
<table width="100" border="0" class="rightside">
<tr bgcolor="#3399ff">
<td>
text
</td>
</tr>
<tr >
<td bgcolor="#3399ff">
text
</td>
</tr>
Yup, just change the word "colour," to "rightside"....
<style type="text/css">
table.rightside
{
background-color:#3399ff;
}
</style>
<table width="100" border="0" class="rightside">
<tr>
<td>
text
</td>
</tr>
<tr>
<td>
text
</td>
</tr>
</table>
milk4cats
02-22-2003, 02:44 PM
Ok, I got it to work with this ...
<STYLE TYPE="text/css">
<!--
table.rightside
tr
{
background-color:#3399ff;
}
td
{ font-family: arial; font-size: 12; color: white; }
A:link
{ text-decoration: none; color:#ffffff }
-------------------------------------------------------------------------------
It seemed the tr / td had to be the 1st things in the class for it to work properly too
Thanks