Styling select element box in CSS

Styling select element box in CSS

In this tutorial, we are going to learn about how to style a <select> element box in CSS.

By default select element styling varies from browser to browser, so that we can create our own custom styling to look the same in all browsers.

This example shows you how to style a select dropdown with your own styling.

<select>
    <option>Apples</option>
    <option selected>Pineapples</option>
    <option>Chocolate</option>
    <option>Pancakes</option>
</select>
select {
  margin: 50px;
  width: 550px;
  font-size:17px;
  padding: 10px 35px 10px 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  height: 54px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: url(http://tuckeralbin.com/wp-content/uploads/intense-cache/icons/plugin/font-awesome/angle-double-down.svg);
  background-repeat:no-repeat;
  background-size: 5%;
  background-position: 98% 50%;
}

select::-ms-expand {
    display: none; /* remove default arrow on ie10 and ie11 */
}

In this above example, we are using appearance:none css property to hide the select element arrow then we added our own arrow using background css property.

background-size property is used to set the size of a dropdown arrow.

background-position property is used to position the arrow in the x-axis and y-axis.

Demo 1

Demo 2

In this demo, we have changed background-color and font-family to the select element.