I'm looking to style some radio buttons in a group. I cannot use any JS, so only css.
<input type="radio" name="attr_1" value="1">
<input type="radio" name="attr_1" value="2">
<input type="radio" name="attr_1" value="3">
<input type="radio" name="attr_1" value="4">
<input type="radio" name="attr_1" value="5">
With the :checked selector I can change the appearance for the selected input but I want to be able to select all radio buttons with a lower value than the one I have checked.
input[type='radio'] {
background-color: red
}
input[type='radio']:checked + input {
background-color: black
}
For example, if the radio button with value 3 is selected it will have a red background but I also want the 1 & 2 to have a red background. Using JS I would easily do this, but I can only use CSS.
Is there any way i can have all following inputs instead of only the 1 input behind the ckecked one?