Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
CSS :checked doesn't apply to selected option

I'm having some trouble getting a simple CSS rule to work. I want to have an option field in a select element change it's color when it's selected. According to w3school :checked would be the correct selector as it applies to input and option. It might be a totally easy fix but I can't figure out what's wrong. Any ideas?

#location-options select option:checked {
    color: red;
}
<form id="location-options">
  <select name="location-category" id="location-category">
    <option value="">Select</option>
    <option value="test1">Imbiss</option>
    <option value="test2">Restaurant</option>
  </select>
</form>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

check this example , using css I have changed the design of checked option, hope this will help

     <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>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!