<ul>
  <li id="red">
    <input value="Red">
  </li>
  <li id="blue">
    <input value="Blue">
  </li>
  <li id="yellow">
    <input value="Yellow">
  </li>
</ul>
#red:focus-within {
  background-color: red;
}

#blue:focus-within {
  background-color: blue;
}

#yellow:focus-within {
  background-color: yellow;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.