?
Solved

CSS - Select Element

Posted on 2011-10-14
4
Medium Priority
?
189 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:Richard Korts
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
twohawks earned 2000 total points
ID: 36971493
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
 

Author Comment

by:Richard Korts
ID: 36971516
To twohawks:

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

Right?

Thanks
0
 
LVL 8

Expert Comment

by:twohawks
ID: 36971584
Try it!  (==yes  ;^)
0
 
LVL 8

Expert Comment

by:twohawks
ID: 36971979
Thanks for the points.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question