Is there a way to modify the background color of the label associated with a checked radio button using Django's form rendering structure? Here is an example of how Django renders form radio inputs:
<label for="id_form-level_0">
<input type="radio" name="form-level" value="1" required="" id="id_form-level_0">
description
</label>
I am not looking to change this structure, so the commonly used solution of
input[type="radio"]:checked + label {
background-color: red;
}
does not work in this scenario. Furthermore, it appears that the :has() selector is not universally supported by browsers, rendering the following code ineffective as well:
label:has(input[type="radio"]:checked) {
background-color: red;
}
What alternate approach should be taken to target the correct label using CSS?