Make half of <option> text red

Discussion in 'CSS' started by Tony Brar, Jul 20, 2012.

  1. #1
    I would like to have an HTML <option> tag, except I want some of it to be red. For example:

    <select>  <option>Volvo</option>  <option selected="selected">Saab</option>  <option>Mercedes <span style="color:red;">- 10% off!</span></option>  <option>Audi</option></select>
    HTML:
    but that doesn't work.

    How would I turn part of it red, but not the whole thing?
     
    Tony Brar, Jul 20, 2012 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    You don't... OPTION is not meant to be styled and can only contain CDATA -- in other words they cannot contain tags. Some browsers (opera, webkit, IE) last I checked won't even let you set color/background on them different from their parent SELECT.

    From the DTD:
    <!ELEMENT OPTION - O (#PCDATA) -- selectable choice -->

    #PCDATA means no tags, just flat text.
     
    deathshadow, Jul 20, 2012 IP