Categories
CSS

How to hide a option in a select menu with CSS?

Spread the love

Sometimes, we want to hide a option in a select menu with CSS.

In this article, we’ll look at how to hide a option in a select menu with CSS.

How to hide a option in a select menu with CSS?

To hide a option in a select menu with CSS, we can add the hidden attribute to the option element we want to hide.

For instance, we write

<select>
  <option>Option1</option>
  <option>Option2</option>
  <option hidden>Hidden Option</option>
</select>

to hide the last option by adding the hidden attribute to the last option element.

Conclusion

To hide a option in a select menu with CSS, we can add the hidden attribute to the option element we want to hide.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *