HTML Form How to - Hide select option with display attribute








Question

We would like to know how to hide select option with display attribute.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!-- ww  w  . j a v a2s .c o m-->
<body>
  <select>
    <option>blue</option>
    <option style="display: none">yellow</option>
    <option>a</option>
  </select>
</body>
</html>

The code above is rendered as follows: