HTML <option> disabled Attribute
Definition and Usage
disabled
The attribute is a boolean attribute.
When present, it specifies that the option should be disabled.
Disabled options are not available and cannot be clicked.
Can be set disabled
The attribute is set to prevent the user from selecting this option until certain other conditions are met (such as checking a checkbox, etc.). Then, a JavaScript is needed to remove the disabled value to make the option selectable.
Example
A dropdown list with a disabled option:
<label for="cars">Please select a car brand:</label> <select id="cars"> <option value="audi" disabled>Audi</option> <option value="byd">BYD</option> <option value="geely">Geely</option> <option value="volvo">Volvo</option> </select>
Syntax
<option disabled>
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 8.0 | Support | Support | Support |