3

For a website I am creating I need to have nested HTML tables. I have styling for the first outside table row (header) that I don't want to be applied for the first rows of the inside tables so I tried using the child combinator like so:

 table.outside > tr:first-child {
      # Outside table header row styles
 }

However, the style do not get applied to the header row of the outside table but when I remove the child combinator it works.
Here is my HTML:

 <table class="outside">
      <tr><!-- This should be styled -->
           <th>Column 1</th>
           <th>Column 2</th>
      </tr>
      <tr>
           <td>
                <table>
                     <tr><!-- Table Data --></tr><!-- This should not be styled -->
                     <tr><!-- Table Data --></tr>
                </table>
           </td>
      </tr>
      <!-- Etc. -->
 </table>

What am I doing wrong?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
1000000000
  • 639
  • 4
  • 17

1 Answers1

4

You can try this selector table.outside > tbody > tr:first-childbut if you share your code, my help would be better.

amatellanes
  • 3,645
  • 2
  • 17
  • 19