HTML: Create select with placeholder

Non-selectable default text for dropdown elements in HTML.

Input fields like the normal input field in HTML have the possibility to define a placeholder. The list or select element does not have this possibility directly. However, it can be easily realised:

<label>list
<select>
    <option value="" disabled selected>Please select</option>
    <option value="value 1">value 1</option>
</select>
</label>

The first element is disabled and thus cannot be selected by the user.

Leave a Reply

Your email address will not be published. Required fields are marked *