css to style table but keep other tables unformatted

I have several tables on my page, but this one table in particular i would like to style using css.

i was wondering how to write it so that only the one table is affected, so if i had the style rules:

table {background-color: #616684;}
thead td {background-color: #ffffff;}
tbody td {background-color: #FFFFFF;}
table
{
border: 0;
width: 100%;
}
td
{
text-align: center;
padding: 5px;
background-color: #FFFFFF;
color: #000066;
}

this would affect only the table i choose - how do i do this?
do i need to label each tr and td in the chosen table as something like:

<table id = "cssTable">
<tr
<td id = "cssTD"></td>
<td id = "cssTD"></td>
etc

thanksTry something like this:

<style type="text/css">
table#cssTable {
background-color: #616684;
border: 0;
width: 100%;
}
#cssTable thead td {
background-color: #ffffff;
}
#cssTable tbody td {
background-color: #fff;
}
#cssTable td {
text-align: center;
padding: 5px;
background-color: #fff;
color: #006;
}
</style>You can either id the table as pyro shows or you can wrap the table (and possibly some other associated elements) in a div with an id. Either way you need to try to keep from adding redundant class names to each equivalent element (like the <td>s).

<tr
<td id = "cssTD"></td>
<td id = "cssTD"></td>
etc

BTW, this is wrong. An id should only be used once on a page. What you need there would be classes.thats worked perfectly pyro, thanks for your help, and for your comments ray.

When should i use a class instead of an id then? i can't really see a difference between the two.Use a class if there will be more than on element using the styles, and an ID when there will only be one (unique).
 
Back
Top