<div class="demo-container">
  <h2>:has() more at least 5 items:</h2>
  <table>
    <tr>
      <td>Apple</td>
      <td>Banana</td>
      <td>Orange</td>
    </tr>
    <tr>
      <td>Kiwi</td>
      <td>Papaya</td>
      <td>Grapefruit</td>
    </tr>
    <tr>
      <td>Grape</td>
      <td>Apple</td>
      <td>Banana</td>
    </tr>
    <tr>
      <td>Orange</td>
      <td>Kiwi</td>
      <td>Papaya</td>
    </tr>
    <tr>
      <td>Grapefruit</td>
      <td>Grape</td>
      <td>Apple</td>
    </tr>
  </table>
</div>
<div class="demo-container">
  <h2>Does not have 5 items:</h2>
  <table>
    <tr>
      <td>Apple</td>
      <td>Banana</td>
      <td>Orange</td>
    </tr>
    <tr>
      <td>Kiwi</td>
      <td>Papaya</td>
      <td>Grapefruit</td>
    </tr>
    <tr>
      <td>Grape</td>
      <td>Apple</td>
      <td>Banana</td>
    </tr>
    <tr>
      <td>Orange</td>
      <td>Kiwi</td>
      <td>Papaya</td>
    </tr>
  </table>
</div>
table {
  margin-bottom: 30px;
  border-collapse: collapse;
  width: 100%;
  background: #dedede;
  border:  1px solid #555;
}

table tr:not(:last-child) {
  border-bottom: 1px solid #555;
}

table td {
  padding: 12px;
}

table:has(tr:nth-child(5)) tr:nth-child(odd) {
  background: hotpink;
  color: #FFF;
}

/************************
Generic layout 
**************************/

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 48px 0;
  font-family: "Figtree", sans-serif;
  font-size: 1rem;
  line-height: 1.5rem;
  background-image: linear-gradient(180deg, #D4C2FC, #998FC7);
  min-height: 100vh;
}

.demo-container {
  max-width: 700px;
  margin: 0 auto;
  background: #FFF;
  padding: 24px;
  border-radius: 10px;
  box-shadow: rgba(17, 17, 26, 0.1) 0px 0px 16px;
}

h2 {
  font-size: 1.5rem;
}

.demo-container + .demo-container {
  margin-top: 50px;
}
Run Pen

External CSS

  1. https://fonts.googleapis.com/css2?family=Bebas+Neue&amp;family=Figtree:wght@300;600&amp;display=swap

External JavaScript

This Pen doesn't use any external JavaScript resources.