Answers for "how to add placeholder in select dropdown"

8

html select placeholder

Placeholder attribute does not exist for the <select> tag.
But there are some ways to make a placeholder for the select box.
The easiest way of making a placeholder for the <select> element is using the disabled and selected attributes with the HTML5 hidden global attribute.
  
<select name="monthname" required>
  <option value="" selected disabled hidden>Select Month</option>
  <option value="Jan">January</option>
  <option value="Feb">February</option>
  <option value="Mar">March</option>
  <option value="Apr">April</option>
  <option value="May">May</option>
  <option value="Jun">June</option>
  <option value="Jul">July</option>
  <option value="Aug">August</option>
  <option value="Sep">September</option>
  <option value="Oct">October</option>
  <option value="Nov">November</option>
  <option value="Dec">December</option>
</select>
Posted by: Guest on April-22-2020
1

how do i make a placeholder for a 'select' box

<html>
  <head>
  </head>
  <body>
  <select required
  		<!-- The following line is the placeholder -->
        <option value="" disabled selected hidden>Choose Gender...</option>
        <option>Male</option>
        <option>Female</option>
    </select>
   <body>
   </html>
Posted by: Guest on December-21-2020
0

How do I make a placeholder for a 'select' box?

<select>
    <option value="" disabled selected>Select your option</option>
    <option value="hurr">Durr</option>
</select>
Posted by: Guest on April-28-2021

Code answers related to "how to add placeholder in select dropdown"

Browse Popular Code Answers by Language