Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

CSS apply to selected option in select tag

<form id="location-options">
        <select name="location-category" id="location-category">
            <option value="">Select</option>
            <option value="test1">Imbiss</option>
            <option value="test2" selected>Restaurant</option>
            <option value="test1">Imbiss</option>
            <option value="test2">Restaurant</option>
        </select>
    </form>
    <style>
        #location-options select option[selected],
        #location-options select option:hover,
        #location-options select option:focus,
        #location-options select option:active,
        #location-options select option:checked {
            background: red;
            color: white
        }
    </style>
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #CSS #apply #selected #option #select #tag
ADD COMMENT
Topic
Name
7+2 =