Problems with creating placeholders for HTML selection boxes

Problems with creating placeholders for HTML selection boxes

I'm using a placeholder in a text input and it works fine. But I also want to use a placeholder for my select box. Of course, I can use the following code:

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

But the "Choose Your Option" is black instead of light grey. So my solution would probably be CSS based. jQuery is also good.

This will just grey out the options in the dropdown menu (so after clicking the arrow):

option:first {
    color: #999;
}

The question is: How do people create placeholders in select boxes? But it has been answered, hurray.

Using this method causes the selected value to always be greyed out (even after selecting a real option):

select {
    color: #999;
}

Solution:

Non-CSS - no JavaScript/jQuery answer:

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

The above is the detailed content about the problem of creating placeholders in html selection boxes. For more information about html selection box placeholders, please pay attention to other related articles on 123WORDPRESS.COM!

<<:  HTML CSS3 does not stretch the image display effect

>>:  Display special symbols in HTML (with special character correspondence table)

Recommend

Tutorial on using Webpack in JavaScript

Table of contents 0. What is Webpack 1. Use of We...

MySQL transaction concepts and usage in-depth explanation

Table of contents The concept of affairs The stat...

Common HTML tag writing errors

We better start paying attention, because HTML Po...

MySQL 5.7.10 installation and configuration tutorial under Windows

MySQL provides two different versions for differe...

MySQL learning notes help document

View system help help contents mysql> help con...

A brief introduction to Tomcat's overall structure

Tomcat is widely known as a web container. It has...

Install Zookeeper under Docker (standalone and cluster)

After starting Docker, let's take a look at t...

Analysis of MySQL's planned tasks and event scheduling examples

This article uses examples to describe MySQL'...

CSS border half or partially visible implementation code

1. Use pseudo-classes to display half of the Bord...

50 Super Handy Tools for Web Designers

Being a web designer is not easy. Not only do you...

The most convenient way to build a Zookeeper server in history (recommended)

What is ZooKeeper ZooKeeper is a top-level projec...

How to add custom system services to CentOS7 systemd

systemd: The service systemctl script of CentOS 7...

Web Design Tutorial (5): Web Visual Design

<br />Previous article: Web Design Tutorial ...