Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

I'm using placeholders for text inputs which are working out just fine. But I'd like to use a placeholder for my selectboxes as well. Of course, I can just use this code:

<select>

    <option value="">Select your option</option>

    <option value="hurr">Durr</option>

</select>

But the 'Select your option' is in black instead of light grey. So my solution could possibly be CSS-based. jQuery is fine too.

This only makes the option grey in the dropdown (so after clicking the arrow):

option:first {

    color: #999;

}

Edit: The question is: how do people create placeholders in selectboxes? But it has already been answered, cheers.

And using these results in the selected value always being grey (even after selecting a real option):

select {

    color:#999;

}

1 Answer

0 votes
by (40.7k points)

Try the code given below:

<select>

<option value="" disabled selected>Select your option</option>

<option value="hurr">Try another option</option>

</select>

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...