English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML option disabled attribute

The disabled attribute of the option element is a boolean attribute. If present, it specifies that an option should be disabled. Disabled options are not available and cannot be clicked.

 HTML <option> tag

Online Example

A dropdown list with a disabled option:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <option disabled attribute</title> - 基础教程网(oldtoolbag.com)</title>/title>
</head>
<body>
<select>
  <option value="PHP" disabled>PHP</option>/option>
  <option value="HTML">HTML</option>/option>
  <option value="C++">C++</option>
  <option value="GOLANG">GOLANG</option>/option>
  <option value="JAVA">JAVA</option>/option>
</select>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the disabled attribute.

Note:Internet Explorer 7 and earlier versions do not support the disabled attribute of the <option> tag.

Definition and Usage

The disabled attribute is a boolean attribute.

If present, it specifies that an option should be disabled.

Disabled options are not available and cannot be clicked.

The disabled attribute can be set to prevent the user from selecting the option until other conditions are met (such as checking a checkbox, etc.). Then, JavaScript is needed to remove the disabled value and make the option selectable.

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, attribute shorthand is prohibited, the disabled attribute must be defined as <option disabled="disabled">.

Syntax

<option disabled>
 HTML <option> tag