Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda