How to style an option in a dropdown, How to style an option in a dropdown |
How to style an option in a dropdown, How to style an option in a dropdown |
Nalini |
Oct 19 2016, 10:42 AM
Post
#1
|
Group: Members Posts: 3 Joined: 19-October 16 Member No.: 24,893 |
Hello,
I want to style a particular option which has a value of -1 in a dropdown. How should I target it? Please advice. |
Christian J |
Oct 19 2016, 11:46 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
If the OPTION element's VALUE attribute is specified you might use an attribute selector, like this:
CODE option[value="-1"] {color: red;} <select> <option value="1">foo</option> <option value="0">bar</option> <option value="-1">baz</option> </select> If the VALUE attribute is not specified (a value can be specified with the OPTION's content as well) the above won't work, though. |
Nalini |
Oct 19 2016, 12:20 PM
Post
#3
|
Group: Members Posts: 3 Joined: 19-October 16 Member No.: 24,893 |
If the OPTION element's VALUE attribute is specified you might use an attribute selector, like this: CODE option[value="-1"] {color: red;} <select> <option value="1">foo</option> <option value="0">bar</option> <option value="-1">baz</option> </select> If the VALUE attribute is not specified (a value can be specified with the OPTION's content as well) the above won't work, though. Thank you so much! Worked like a charm. |
Lo-Fi Version | Time is now: 18th April 2024 - 09:22 PM |