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 show button hovering above an image or pressing over it? [closed]

    How to change CSS based on Season using JavaScript

    How to let a div behave like another div?

    How to make tabs on the web page?

    How to remove class using CSS

    How can I force Internet Explorer to apply CSS styles

    How to make CSS apply to only a portion of the link_to text?

    How to place a consistent 5px margin around an inner div without specifiying inner divs height?

    how to make form input in middle

    How to remove unwanted white space in CSS

    Bootstrap - How to keep the natural container layout while fixing the container to the bottom?

    How to apply css style when using ng-print inAngular JS

    How to show “…” when there's not enough space to view all the text

    Div / CSS / ZIndex - how to overlap pictures?

    How to flatten checkbox using CSS? [duplicate]

    How to add style to the parent when radio button is selected

    How to emulate table cells with CSS (without float)?

    How to add 'important' to zIndex

    How to apply css to particular selected child in ivh-treeview?

    How to change active color of bootstrap button group to have different color for each button

    Slideshow with specific Text on each Image

    How to fix the Height for this area?

    How do you tell a browser, “if you need to wrap, wrap here first”?

    HTML/CSS/JS: How to force browser to save password from a non-'password' type input?

    How to create two column in form using css

    How can I have a CSS style different for IE6?

    How to render email template in a page?

    How do I bottom-align bars in a CSS vertical bar chart?

    How to make my twitter bootstrap overlap all other elements?

    How to make child elements from parent1 have a higher z-index than child elements from parent 2 (with same z-index as other parent)?