DEV Community

Cover image for How to add a placeholder on a select
Sara Ounissi
Sara Ounissi

Posted on β€’ Originally published at thetrendycoder.com

2

How to add a placeholder on a select

It is quite easy to add a placeholder on a select in HTML, you just need to add an option with the text you need as a placeholder. The only thing to look for is to empty the value, add the two properties selected and disabled.

<select> 
    <option value="" disabled selected>Select your option</option>
    <option value="test">Test</option>
</select>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay