Bootstrap 3.3.7
I have a <select>
element and wanted to use the placeholder
attribute. I read this isn't possible and it should just be done as a disabled
option like this:
<select id="foo">
<option value="" disabled selected>Select your thing</option>
<option value="abc">abc</option>
<option value="def">def</option>
</select>
The trouble is, Bootstrap gives this a dark grey colour (#555
) because it's treating it like text in other (non-select) text inputs.
The placeholder colour of the font in Bootstrap is a lighter grey (#999
). I want it to match.
But, I cannot find a way to target that option. I've tried the following:
#foo option:disabled { color: #999; }
And giving the first option a class, e.g.
<option value="" class="placeholder-dummy" disabled selected>Select your thing</option>
.placeholder-dummy { color: #999; }
The only way I could in any way target it was just using the ID like this:
#foo { color: #999; }
But... that gives the same light grey placeholder colour even after the user changes the option.
I want the "placeholder" ("Select your thing") light grey (#999
) but when the user changes it to any other option, for those to take the darker grey as per the other inputs (#555
)
Is this possible?
Edit would prefer a pure CSS solution but as this is looking impossible a JavaScript solution would be ok.