Clive Clive - 4 years ago 131
CSS Question

How do I specify CSS cell padding for multiple tables?

I have two (maybe three or more) tables on a page and I want table A to have cell padding 10px, table B to have padding 20px. Making a CSS td element such as

{padding: 10px;}
is no good because both tables would be 10px. And I don't want to have to put
class="diffpad"
on every single
<td>
of the second table. Basically, I want to specify one padding for all the cells of one table, and a different padding size for all the cells of a second table. But, as you know, you can't add the padding style to a table element. So how do you do it without repeating yourself a million times for each and every
<td>
element?

Answer Source

Try giving unique id to each of the tables (not tds) and you can do this.

#table1 td{
    padding:10px;
}
#table2 td{
    padding:20px;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download