I'm trying to style a select box, changing all of the color options to red. However, when I load the webpage the select box still has color black. Any help please?
Here is the HTML & CSS:
select.selector option {
color: red;
}
<select style="font-size: 16px; padding: 4px;" name="category" id="categoryselector" class="selector">
<option disabled></option>
<option value='all'>all</option>
<option disabled></option>
<option>Hardware and OS</option>
</select>
And here is a JSFiddle
The select is set to display: block by default but you can style it display: inline-block; width: auto; if you'd like it to sit alongside a label .
There are many ways to design a <select> dropdown menu using CSS. The Dropdown Menu is mainly used to select an element from the list of elements. Each menu option can be defined by an <option> element that can nested inside the <select> element.
To change the selected option background-color CSS style, we can set the style attribute of the select and option elements. to set the whole select element to background color 009966 and color FFF . Then we override the the styles in the option elements with style="background: white; color: black;" .
Select option styling doesn't work in Chrome (MAC OS X), but it will work in Firefox on all systems as well as Chrome (Windows 7).
You can check the detailed description here: Dealing with the select nightmare
You're applying the color to the options within the select box. To apply it to the visible select box, use:
select.selector{
color:red;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With