Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to change the color of select text

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>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading