CSS - Select Element

I need to show different elements in an html select pulldown list in different colors.

Is it OK to assign inline style at the <option> level?

How is that done?

Thanks
Richard KortsAsked:
Who is Participating?
 
twohawksCommented:
Sure you can.
Samples below.

Innumerable citings on the web discuss the considerations of inline/stylesheet methods, for instance,
http://webdesign.about.com/od/css/a/aa073106.htm
...so I see no need to get into that here, only to say you do well to read up a bit on that.

If I have a one-off situation I may use inline styling until I get around to classifying the tag/tag-group.

<ol id="mylist" style="background-color:blue;">

	<li style="background-color:red;">1</li>
	<li style="background-color:orange;">2</li>
	<li style="background-color:yellow;">3</li>
	<li style="background-color:green;">4</li>
	<li style="background-color:blue;">5</li>
	<li style="background-color:violet;">6</li>

</ol>

<select>
  <option style="background-color:red;">Volvo</option>
  <option style="background-color:orange;">Saab</option>
  <option style="background-color:green;">Mercedes</option>
  <option style="background-color:blue;">Audi</option>
</select>

Open in new window

0
 
Richard KortsAuthor Commented:
To twohawks:

I meant the text color, but I guess it can just be
style="color:red;"?

Right?

Thanks
0
 
twohawksCommented:
Try it!  (==yes  ;^)
0
 
twohawksCommented:
Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.