Style is not influenced by the css for – Aprillion Feb 14 '16 at 09:39

  • @Aprillion I just tried the fiddler on `Chrome 48.0.2564.109 m` and `IE 11.0.9600.17239` it still worked. Can you confirm you don't have so other CSS or JS influencing the select element? – Justin Feb 15 '16 at 14:04
  • did you compare with accepted answer? the fiddle here works the same as in question. but the select itself is not styled. – Aprillion Feb 15 '16 at 14:11
  • @Aprillion Ahh, I see what you mean. I'm looking at this, but I think Chrome and IE treat the select and option list as seperate elements. That is why the selected option's background color doesn't get properly rendered. My have to resort to some JS trickery to get the desired effect. – Justin Feb 15 '16 at 14:39
  • 1

    Pure CSS Method:-

    You can style it if you want to apply style if empty value selected using :valid selector like the following code

    Display in Red If Selected value is Empty

    select > option {
      color: black;
      font-weight:initial;
    }
    select option[value=""] {
      color: red;
      font-weight:bold;
    }
    select[required]:invalid {
      color: red;
      font-weight:bold;
    }
    <select required name="fontSize">
    <option value="">Please select</option>
    <option value="9">9 px</option>
    <option value="10">10 px</option>
    <option value="11">11 px</option>
    <option value="12">12 px</option>
    <option value="13">13 px</option>
    <option value="14">14 px</option>
    <option value="15">15 px</option>
    <option value="16">16 px</option>
    </select>
    <select required name="fontColor">
    <option value="">Please select</option>
    <option value="red" selected>Red</option>
    <option value="green">Green</option>
    <option value="blue">Blue</option>
    </select>
    jafarbtech
    • 5,941
    • 1
    • 29
    • 49