How to add a placeholder for a select box

Today we will show you how to add a placeholder for a select box in HTML. The placeholder attribute does not exist in the select tag but we have a couple of alternatives to show the placeholder for a select tag.

Here we will show you the best and easy way to show the placeholder for a select dropdown.

In the verify the first step, we have to add the placeholder as a first option in the select tag as an empty string and set the disabled, selected, and hidden for the placeholder option. Look at the small example.

index.html

In the above example, we set the color gray for the placeholder. Run the HTML and check the output in the browser.

Output

Output - How to add a placeholder for a select box - Clue Mediator
Output – How to add a placeholder for a select box – Clue Mediator

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

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