Ali Sheikhpour
Ali Sheikhpour

Reputation: 11096

Can not reset TD style

I have removed padding from all TD elements in stylesheet. But I have a special table having cellpadding="10". Its TD are rendered having 0px padding due to above mentioned style.

how should I reset TD padding to nothing so it inherits the 10px padding from cellpadding?

td {padding:0}

#specialtable td { 
  /* What should I write here? */ 
}
<table id="specialtable" cellpadding="10" style="border:1px solid #555555">
  <tr>
    <td>test</td>
   </tr>
 </table>

Upvotes: 2

Views: 98

Answers (2)

Lajos Arpad
Lajos Arpad

Reputation: 76943

From here one can see that we can define an inherit value for the padding, which should inherit the padding from the parent. As far as I know that is the default value. So you can set the padding to default by giving it the inherit value.

Upvotes: 0

noisypixy
noisypixy

Reputation: 774

You can use the :not pseudo-class to define the padding for all td except those under a #specialTable.

table:not(#specialTable) td {
  padding: 0;
}
<table id="specialTable" cellpadding="10" style="border:1px solid #555555">
  <tr>
    <td>test</td>
  </tr>
</table>

Upvotes: 1

Related Questions