I am trying to add CSS content ::beforeto tags <option> <select multiple>depending on whether the option is selected or not.
The below currently works fine in Chrome and FF, but I am having problems with IE11.
select > option::before {
display: inline-block;
width: 10em;
}
select > option:checked::before {
content: "SELECTED: ";
}
select > option:not(:checked)::before {
content: "excluded: " ;
}
<select multiple>
<option value="1" selected="selected">1</option>
<option value="2" selected="selected">2</option>
<option value="3" selected="selected">3</option>
<option value="4" selected="selected">4</option>
<option value="5" selected="selected">5</option>
</select>
Run codeHide resultI read other SO ( 1 , 2 , 3 , 4 ) posts about pseudo elements in IE, and most of them seem to point to setting some kind of attribute positionor displayone that I tried.
<option>Does this happen because tags should not contain children?
source
share