How to make a placeholder for a select box with HTML?

Spread the love

Sometimes, we want to make a placeholder for a select box with HTML.

In this article, we’ll look at how to make a placeholder for a select box with HTML.

How to make a placeholder for a select box with HTML?

To make a placeholder for a select box with HTML, we can add an option that’s disabled.

For instance, we write

<select>
  <option value="" disabled selected>Select your option</option>
  <option value="hurr">Durr</option>
</select>

to add an option element that has the disabled attribute.

And we add the selected attribute to make it the selected option by default.

Conclusion

To make a placeholder for a select box with HTML, we can add an option that’s disabled.

Leave a Reply

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