Click to See Complete Forum and Search --> : Shade or have different color for every alternate row within a table.


cakeday
07-07-2003, 12:40 PM
Is there a way in within an HTML Table where i can shade or have a different color for every alternate row??

Thank you!!

spufi
07-07-2003, 01:20 PM
In your <head> tag...

<style type="text/css">
<!--
.shade1 { background-color:#CCCCCC; }
.shade2 { background-color:#AAAAAA; }
-->
</style>

In your tabe code...

<tr class="shade1">
<td>Text</td>
</tr>
<tr class="shade2">
<td>Text</td>
</tr>

cakeday
07-07-2003, 01:32 PM
Thank you, Spufi! BUT,
I want to have different color for alternate table rows.
My table is being populated with data from the database table and is within a loop, so i cannot try what Spufi asked me to do..
Is there any other way of doing it?

My code looks as follows..


My code right now looks like,
<table border="0">
<TR>
<TH>HEADER1</TH>
<TH>HEADER2</TH>
<TH>HEADER3</TH>
<TH>HEADER4</TH>
<TH>HEADER5</TH>
<TH>HEADER6</TH>
<TH>HEADER7</TH>
<TH>HEADER8</TH>
<TH>HEADER9</TH>
</TR>

LOOP
CODE...............(that populates the table)

<TR>
<TD>DATA1</TD>
<TD>DATA2</TD>
<TD>DATA3</TD>
<TD>DATA4</TD>
<TD>DATA5</TD>
<TD>DATA6</TD>
<TD>DATA7</TD>
<TD>DATA8</TD>
<TD>DATA9</TD>
</TR>
<TR>
<TD>DATAa</TD>
<TD>DATAb</TD>
<TD>DATAc</TD>
<TD>DATAd</TD>
<TR>
<hr>

END LOOP
</TABLE>