How to make a placeholder for select box in HTML
Short tutorial on how we can add placeholder text for the select option element for dropdown in Html without CSS.
In this article, we will see how to add a placeholder in the <select> tag for multiple dropdowns of HTML.
To add a placeholder to <select> dropdown, we have to use the <option> tag and add disabled, hidden, and selected attributes to it.
The placeholder attribute is used to indicate what type of value is expected from a user.
Here is an example of using placeholder attributes to add placeholder text in a form.
<form> <input placeholder="Enter Name" /> <textarea placeholder="Enter your message" /> </form>
The output will be like this,

However, in < select > element we do not get the placeholder attribute to write the text.
So what we can do is use the < option > tag along with the disabled and selected attributes to write the placeholder text in it.
Example:
<select> <option value="" disabled selected hidden>Select a color</option> <option value="blue">Blue</option> <option value="green">Green</option> <option value="red">Red</option> <option value="yellow">Yellow</option> </select>
The disabled attribute make the option unable to select from the options.
The selected attribute specifies the option that should be pre-selected when the page loads.
The hidden attribute hides the option when we open the drop-down from the < select > box on a page.
Related Posts
How to change the color of <hr> tag using CSS
Here we will learn how to change the color or the background color of HR element in out html using css style.
Horizontal scrolling div with arrows using HTML and CSS
Tutorial on how to make horizontal scrolling div with arrows using html and css and for smooth scrolling we will use scrollBy() function in Javascript.
What is insertAdjacentHTML() ? How to use it?
Tutorial on Javascript insertAdjacentHTML() method and how can we use it to insert html elements to specific position in our HTML page.
How do I wrap text in <code> tag HTML
This article is on how to wrap text in code tag in html. We will use white-pace, word-break and word-wrap CSS property to get our result.
