HTML <option> Tag with the 'disabled' Attribute
<select name="Food">
<option value ="apples">Apples</option>
<option value ="bananas">Bananas</option>
<option value ="oranges" disabled>Oranges</option>
</select>
The above example demonstrates usage of the disabled
attribute when using the <option>
element. In this example, the Oranges option has been disabled.
The disabled
attribute is used to disable a given <option>
element. This particular element won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
Boolean Attribute
The disabled
attribute is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either disabled
or disabled="disabled"
).
Possible values:
- [Empty string]
- disabled
You can also disable a group of <option>
elements by disabling the <optgroup>
element.