Search code examples
htmlcssdropdownhtml-select

How do I change the background color of the main cell of a html dropdown?


To put it very simple, I want to change the background color of the main field (not sure what else to call it, it's the field marked in red in the example) of a HTML element. I do not want to change the background color of the dropdown fields.

Is this possible? If so, how?

enter image description here

Source code:

<select>
   <option>Item 1</option>
   <option>Item 2</option>
   <option>Item 3</option>
</select>

Solution

  • One way would be to style de select and the option

    option{
      background-color: white;
    }
    
    select { 
      background-color: yellow;
    }
    <select>
       <option value="3">tewe</option>
       <option value="8">eerer</option>
       <option value="5">ererere</option>
    </select>