CSS selector for SELECT html element with nothing selected -


i know used word select lot there... sorry.

anyway, looking css selector can use identify html select elements on page not have selection made yet can highlight them user know elements still need completed. have empty option first element in select, if helps... please use it.

my stupid attempts far: select:empty select[selectedindex="0"]

<select>   <option value="" />   <option value="real selection" /> <select> 

so essentially, want find selects option hasn't been selected, value of selection 0, or index of selection 0. (these equivalent in scenario). way can highlight on screen let user know, "hey, you've got more work do."

fyi: psuedo , css3 selectors fine scenario too.

this isn't possible in css 3.

when selectors level 4 supported (assuming bit doesn't change) can determine subject of selector other last item in selector and:

select {     /* default. put non-selected styles here */ }  !select > option + option:checked {     /* option following option (so not first option) selected */ } 

you'd need make selectors more complex if have optgroup elements deal with.


Comments