How to apply CSS to td of particular table using Classname? [duplicate]


Tags: html,css

Problem :

This question already has an answer here:

How to apply CSS to td of particular table using Classname? (Not ID or Name)

Following is HTML

<table class="pure-table 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 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-top:0; padding-bottom:0;}
  • i want to apply it on td's of table having Classname''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 Classname''NotToBeApplied''

How to modify HTML and CSS to achieve above?



Solution :

Try this

table.ToBeApplied tbody tr td{
padding-top:0; padding-bottom:0;
}

    CSS Howto..

    How to set a box on bottom of a box?

    How to add a ToolTip for an icon inside my CSS file

    How to make image “hang over” above background?

    How to have a box increase its size based on its content?

    How can I centralize a list with css?

    How to get the style value using attr

    how to add a fixed position Box on left side of each post [closed]

    How to get the Apple Javascript Split Flap Counter to run on pure CSS

    Image Filter and Show text on Mouseover

    How to specify max-height css property to Screen size

    How do you create a link out of circular text with JavaScript and CSS?

    How to make my first-child in css work properly?

    How to implement this in pure CSS?

    mkd2pdf, wkhtmltopdf, how to make PDF for slide

    How would you go about placing li in different divs?

    How to fix image loading time with my image slider?

    CSS background color show another color

    How to add arrow beside some links in CSS?

    Bootstrap shows black rectangles when printing focused input elements

    How to include (referencing) CSS Javascript jQuery in master page and content (child) page

    How to change CSS element of data-pid using jquery

    How to get table-row css and border property work together?

    How do you hide and show a background image using a carousel?

    How can I implement dynamic styling for ion-list elements with AngularJS?

    How to time the effect of a css look in javafx?

    how can i get a css table-cell link not to stretch the clickable area

    Bootstrap: Only Show Fixed Footer In Larger Screens?

    How to create rounded shape by CSS

    How to add css class in aspx.cs page means code behind page

    How do I make text-transform:uppercase work properly with Greek?