Languages
[Edit]
EN

HTML - disable select box option

0 points
Created by:
DrJoystick
315

In this article, we would like to show you how to disable the select box option in HTML.

Quick solution:

// ONLINE-RUNNER:browser;

<select>
  <option value="value1" disabled >Option 1</option>
</select>

 

Practical example

In this section, we present a practical example of how to disable a select box option using disabled attribute.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form name="my-form">
    <label>Fruits: </label>
    <select name="my-fruits">
      <option value="banana" disabled>🍌 Banana</option>
      <option value="apple">🍎 Apple</option>
      <option value="grape">🍇 Grape</option>
    </select>
  </form>
</body>
</html>

References

  1. <option>: The HTML Option element - HTML | MDN 
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join