PDA

View Full Version : CSS & tables backgrounds question?



Collectors-info
09-22-2007, 04:39 PM
Hi, I am trying to get a tables with different background colors on the same page.
I have got to the stage where I can place “lets say” 4 tables on 1 pages & via the remote css sheet I can change the background colour via the <tb> tag.
But how do I make each table a different colour?


-----------------------------------------------------------------------------
td
{
background-color: green
}

-------------------------------------------------------------------------------
<table border="0" bordercolor="" width="100" >
<tr>
<s1><td> row 1, column 1 </s1></td>
</tr>
</table>
------------------------------------------------------------------------------
But not sure what I am doing wrong here.http://www.vodahost.com/vodatalk/images/icons/icon5.gif
-------------------------------------------------------------------------------

b1
{
background-color: red
}


<table border="0" bordercolor="" width="100" >
<tr>
<b1><td> row 1, column 1 </b1></td>
</tr>
</table>
----------------------------------------------------------------------------------------------------------



Thanks.

Watdaflip
09-22-2007, 05:31 PM
Your going to want to define a css class for each table

Your css sheet will be something like

.table1
{
background-color: #00FF00;
}

.table2
{
background-color:#0000CC;
}

.table3
{
background-color:#FFFF00;
}

And then your tables html will be this

<table class="table1" width="100">
<tr><td>This has a backgrond</td></tr>
</table>


<table class="table2" width="100">
<tr><td>This has a different background</td></tr>
</table>


<table class="table3" width="100">
<tr><td>As does this</td></tr>
</table>


Further, you will probably want to go ahead and define the tables width in the css file as well, instead of the tables html code itself. ( width: 100px )

Collectors-info
09-22-2007, 07:46 PM
Many, many thanks Watdaflip. I have been playing already. That saved me a lot of time.
http://www.collectors-info.com/testing/css/cssbg.php

Watdaflip
09-22-2007, 09:45 PM
Your welcome, any time.