I have a basic <select>
box with two <option>
s. I want to know if I can give a style
to the <select>
box based on a selected <option>
(which has no ID, only a value), in pure CSS. The CSS that I have here only works for the bottom style, regardless of what option is chosen on page load.
Here is what I have:
#foo,
option[value="2"]:checked {
border: 2px solid #FF9999;
}
#foo,
option[value="1"]:checked {
border: 2px solid #2fa154;
}
<select id="foo">
<option value="1">Bar 1</option>
<option value="2">Bar 2</option>
</select>
Is what I am asking possible with pure CSS without the use of jQuery etc.?