Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply CSS to td of particular table?

Tags:

html

css

How to apply CSS to td of one particular table; excluding all other tables in web page?

<table class="pure-table fullWidth" id="ToBeApplied">
 <tbody>
  <tr class="pure-table-odd">
   <td>
    <label>Bank</label>
   </td>
   <td>
    <label>Japha Bank</label>
   </td>
  </tr>
 </tbody>
</table>
<table class="pure-table fullWidth" id="NotToBeApplied">
 <tbody>
  <tr class="pure-table-odd">
   <td>
    <label>Bank</label>
   </td>
   <td>
    <label>Japha Bank</label>
   </td>
  </tr>
 </tbody>
</table>

I want to apply CSS say

td {padding:23px;font-weight:bold}
  • i want to apply it on td's of table having ID ''ToBeApplied''.
  • I do not want to write a class and write same on each td of table
  • I do not want it to apply on td's of second table have ID ''NotToBeApplied''

How to modify HTML and CSS to achieve above?

like image 858
fatherazrael Avatar asked Jul 28 '15 07:07

fatherazrael


3 Answers

Use CSS selectors like,

#ToBeApplied td {padding:23px;font-weight:bold}
like image 154
sanjeev shetty Avatar answered Oct 16 '22 19:10

sanjeev shetty


This should work (Assuming that you dont want to specify id for table)

table.pure-table:first-child td {padding:23px;font-weight:bold}

DEMO

like image 2
Sowmya Avatar answered Oct 16 '22 19:10

Sowmya


This is what you want.

Check out this fiddle.

#ToBeApplied td {
    padding:23px;
    font-weight:bold
}

Here is the snippet.

#ToBeApplied td {
  padding: 23px;
  font-weight: bold
}
<table class="pure-table fullWidth" id="ToBeApplied">
  <tbody>
    <tr class="pure-table-odd">
      <td>
        <label>Bank</label>
      </td>
      <td>
        <label>Japha Bank</label>
      </td>
    </tr>
  </tbody>
</table>
<table class="pure-table fullWidth" id="NotToBeApplied">
  <tbody>
    <tr class="pure-table-odd">
      <td>
        <label>Bank</label>
      </td>
      <td>
        <label>Japha Bank</label>
      </td>
    </tr>
  </tbody>
</table>
like image 1
Shrinivas Shukla Avatar answered Oct 16 '22 18:10

Shrinivas Shukla