how do you set the background color of an item in an HTML select list?
A:
select.list1 option.option2
{
background-color: #007700;
}
<select class="list1">
<option value="1">Option 1</option>
<option value="2" class="option2">Option 2</option>
</select>
Developer Art
2010-05-07 15:37:02
why use `>` ? `<option>` elements can only ever exist inside a select anyway
nickf
2010-05-07 15:38:15
can you make text inside <option> **bold** also with css?
Bakhtiyor
2010-06-10 20:10:14
unfortunately, this doesn't seem to work in Chrome.
edebill
2010-10-01 21:01:19
A:
Just like normal background-color: #f0f
You just need a way to target it, eg: <option id="myPinkOption">blah</option>
nickf
2010-05-07 15:37:37
+1
A:
I assume you mean the <select>
input element?
Support for that is pretty new, but FF 3.6, Chrome and IE 8 render this all right:
<select name="select">
<option value="1" style="background-color: blue">Test</option>
<option value="2" style="background-color: green">Test</option>
</select>
Pekka
2010-05-07 15:38:37