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

Install redis and MySQL on CentOS

1|0MySQL (MariaDB) 1|11. Description MariaDB data...

A brief introduction to VUE uni-app basic components

1. scroll-view When using vertical scrolling, you...

Nginx proxy forwarding implementation code uploaded by Alibaba Cloud OSS

Preface Because the mini program upload requires ...

How to use the Fuser command in Linux system

What is Fuser Command? The fuser command is a ver...

Some lesser-known sorting methods in MySQL

Preface ORDER BY 字段名升序/降序, I believe that everyon...

MySQL trigger syntax and application examples

This article uses examples to illustrate the synt...

Solution to Nginx 500 Internal Server Error

Today, when I was using Nginx, a 500 error occurr...

Install CentOS system based on WindowsX Hyper-V

At present, most people who use Linux either use ...

How to manually upgrade the node version under CentOs

1. Find the corresponding nodejs package, refer t...

CSS3 uses scale() and rotate() to achieve zooming and rotation

1. scale() method Zoom refers to "reducing&q...

How to automatically deploy Linux system using PXE

Table of contents Background Configuring DHCP Edi...

Metadata Extraction Example Analysis of MySQL and Oracle

Table of contents Preface What is metadata Refere...

Tips for adding favicon to a website: a small icon in front of the URL

The so-called favicon, which is the abbreviation o...

A brief discussion on tags in HTML

0. What is a tag? XML/HTML CodeCopy content to cl...