Is there a way to style the currently selected
The :checked pseudo-class applies to elements with the HTML4 selected and checked attributes. So, this CSS can be used to achieve the desired effect, although not all browsers support styling the color:
option:checked { color: red; }
For instance, if you wanted to hide the currently selected item from the drop-down list, you could use the following CSS:
option:checked { display:none; }
<select> <option>A</option> <option>B</option> <option>C</option> </select>
The above is the detailed content of Can I Style a Selected `` Element in a `` Dropdown?. For more information, please follow other related articles on the PHP Chinese website!