While answering another question I came across this weird bug. A quick search has not found an existing question, so here goes:
JSFiddle: http://jsfiddle.net/TrueBlueAussie/93D3h/4/
<select>
<option>Item1</option>
<option>Item2</option>
<option>Item3</option>
<option class="hidden">Item4</option>
<option class="hidden">Item5</option>
</select>
CSS:
.hidden {
display: none;
}
Q: Why is Item5
always shown, even though it is styled as hidden? Item4
is not visible. Note: I am testing this in the latest version of Chrome.
Update:
Different people are getting different results on different browsers. The following (from answer below) works on Chrome but not on the latest IE (both Item4 and Item5 are shown):
.hidden {
visibility: hidden;
}
Turns out this problem has been hit before (no surprise): How to hide a <option> in a <select> menu with CSS? but the surprising thing is that browsers do not support removing options with styling. Go figure!