The current method of adding a placeholder in your dropdown is to add the disabled
, selected
, and hidden
attributes to one of the <option>
elements in your <select>
menu like so
<select>
<option disabled selected hidden>Placeholder text</option>
<option>First option</option>
<option>Second Option</option>
</select>
This is a bit ugly, but more importantly it also breaks semantics a bit as the <option>
element is not behaving as an option in a list, but as instructional text.
Instead I propose the placeholder
attribute be added to the <select>
element to serve this purpose. It would be shown before the user has selected any options and when no selected
attribute is present on any of the <options>
in the <select>
menu. Perhaps it could have a lighter colored text similar to the placeholder for input elements, but I guess that’s more up to the user agent. Using this proposed attribute, the above code could be rewritten as follows:
<select placeholder="Placeholder text">
<option>First option</option>
<option>Second Option</option>
</select>
I welcome any input, would love to get some feedback, especially if there are any accessibility challenges with this.