Wednesday, 14 August 2013

How to change select element's background color when it's selected?

How to change select element's background color when it's selected?

text
<select>
<option value="a">a</option>
<option value="b">b</option>
</select>
text
::selection {
background-color: yellow;
}
Run HTML and CSS codes above on http://jsfiddle.net/tc99J. Press command-A
to select all stuff. You should see this effect:

You notice the background color of text "a" isn't yellow. How can I change
text "a"'s background color to yellow?
Thank you.

No comments:

Post a Comment