I am using select2 plugin. In the mandatory fields I have to give the select2 placeholder color as red.
How do I change the default select2 placeholder color to red?
HTML
<select id="leadadd_mode_of_enq" name="leadadd_mode_of_enq" class="select2 req_place" data-select-search="true" placeholder="Mode of enquiry">
<option value="1">Opt1</option>
<option value="2">Opt2</option>
</select>
CSS
.req_place::-webkit-select-placeholder{
color:#FFF !important;
}
The default color of a placeholder text is light grey in most browsers. If you want to change it, you need to use the ::placeholder pseudo-element. Note that Firefox adds lower opacity to the placeholder, so use opacity: 1; to fix it.
In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector.
CSS ::placeholder Selector Tip: The default color of the placeholder text is light grey in most browsers.
Note: In most browsers, the appearance of placeholder text is a translucent or light gray color by default.
the answers given are old and you can now use the css class
.select2-selection__placeholder {
color: #FF0000;
}
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