2

<table>
  <thead>
  </thead>
  <tbody class="someclass">
    <tr>
      <td>
      </td>
      <td>
        <table>
          <tbody>
            <tr>
              <td>.....</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

The code snippet above here I want to style first tr of parent table with someclass like:

.someclass tr td{
.......
......
}

but it is getting applied to inner table also.

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
pod
  • 23
  • 7

2 Answers2

2

I liked Gosi's answer about applying 'first-of-type' to your css. But then I read the comments and realised, so thought I'd follow up with this:

Try:

.someclass tr:first-of-type {
background: blue;
}

As per Gosi's answer, then also add this:

.someclass tr table tr:first-of-type {
background: none;
}
jock.perkins
  • 459
  • 8
  • 22
0

You can use following css for this

.someclass > tr {
    // your css here
}

Or

.someclass > tr:first-child {
    // your css here
}

or

.someclass tr:first-of-type {
    // your css here
}
Super User
  • 9,078
  • 3
  • 27
  • 46