HTML Form How to - Style for the select option








Question

We would like to know how to style for the select option.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
option {<!-- www.java  2  s.c om-->
  background-color: red;
}
</style>
</head>
<body>
  <select>
    <option>testing</option>
    <option>testing</option>
    <option>testing</option>
    <option>testing</option>
    <option>testing</option>
  </select>
</body>
</html>

The code above is rendered as follows: