2

I want to change style (color, borders etc...) of certain option in select box.

Example:

<select name="items">
  <option>Select item:</option>
  <option value="item1"> item1 </option>
  <option value="item2"> item2 </option>
  <option vlaue="item3"> item3 </option>
</select>

First option " Select item: " don't have any value, it is more like title of item list. But Im curious is it possible to change style of that option, and make it a bit different from other options in select box?

rango
  • 609
  • 1
  • 7
  • 23

1 Answers1

2

select{
  background:red;
}

option:first-child{
  background:yellow;
  color:green;
}
<select name="items">
  <option>Select item:</option>
  <option value="item1"> item1 </option>
  <option value="item2"> item2 </option>
  <option vlaue="item3"> item3 </option>
</select>
repzero
  • 8,254
  • 2
  • 18
  • 40