Ad

How To Change The Color Of Select Text

- 1 answer

how to change the color of the dropdown text that I am given red but initially it look like black when we click that it look like red, so how to change that initially it look like red color

<select>
  <option style="color:red">one</option>
  <option style="color:red">two</option>
</select>

Ad

Answer

You should apply the style to the select, not to the option.

Setting style="color:red" will set the color of the option to red.

Setting style="color:green" will set the color of select to green

<select style="color:green">
  <option style="color:red">one</option>
  <option style="color:red">two</option>
</select>

If you dont want the color of options to be updated, use color: initial for the option.

select {
  color: red;
}

select option {
  color: initial;
}
<select>
  <option>one</option>
  <option>two</option>
</select>

Ad
source: stackoverflow.com
Ad