how to change color of option tag in select

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kummu4help
    New Member
    • Nov 2008
    • 14

    #1

    how to change color of option tag in select

    can i use like this
    Code:
    <select name="test" >
    <option value="1">option</option>
    <option value="2"><p style="background-color:#FF0055;">again</p></option>
    </select>
    i don't want to use style in the option tag.
    because i am getting the option text from database.
    so i want to apply style to the text only.

    because i have no chance to use styles in the option tag. that is strictly avoided by my existing code.i am allowed to do changes to the text part only.
    i am not allowed to touch option tag or select tag.

    i tried like this also

    Code:
    <option value="2"><font color=red>again</font></option>
    any help pls...
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it would be helpful if you could add an id attribute to every option tag. this would make applying CSS a piece of cake.

    if that's not possible, I can only think of Javascript to solve that.

    besides that, <option> must only contain text (aka #PCDATA).

    Comment

    Working...