CSS - Select Element

Posted on 2011-10-14
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?

Question by:Richard Korts
    LVL 8

    Accepted Solution

    Sure you can.
    Samples below.

    Innumerable citings on the web discuss the considerations of inline/stylesheet methods, for instance, 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>
      <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>

    Open in new window


    Author Comment

    by:Richard Korts
    To twohawks:

    I meant the text color, but I guess it can just be


    LVL 8

    Expert Comment

    Try it!  (==yes  ;^)
    LVL 8

    Expert Comment

    Thanks for the points.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
    CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
    In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now