Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the css of default select2 placeholder color?

Tags:

jquery

css

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;
}
like image 283
user3091530 Avatar asked Apr 11 '14 05:04

user3091530


People also ask

How do I change the default placeholder color?

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.

Can we change placeholder color in CSS?

In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector.

What is the default placeholder color CSS?

CSS ::placeholder Selector Tip: The default color of the placeholder text is light grey in most browsers.

What is the default placeholder text color?

Note: In most browsers, the appearance of placeholder text is a translucent or light gray color by default.


1 Answers

the answers given are old and you can now use the css class

.select2-selection__placeholder {
    color: #FF0000;
}
like image 116
Richard Avatar answered Oct 20 '22 00:10

Richard