HTML Form How to - Style Option in Select input








Question

We would like to know how to style Option in Select input.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.c1 {<!-- w  w w.  j  a va 2s  . c  o m-->
  font-family: courier;
  color: red
}

.c2 {
  font-family: arial;
  font-weight: bold;;
  color: blue;
}
</style>
</head>
<body>
  <span class="c1">this has the class c1</span>
  <br />
  <span class="c2">this has the class c2</span>
  <br />
  <select>
    <option class="c1">this option has c1</option>
    <option class="c2">this option has c2</option>
  </select>
</body>
</html>

The code above is rendered as follows: