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

HTML reference manual

HTML tag大全

HTML optgroup disabled attribute

The disabled attribute is a boolean attribute. If present, it specifies that an option group should be disabled. A disabled option group cannot be used and cannot be clicked.

 HTML <optgroup> tag

Online example

An example of a disabled option group:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <optgroup> disabled attribute - 基础教程网(oldtoolbag.com)</title>
</head>
<body>
<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars" disabled>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</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 <optgroup> tag.

Definition and Usage

The Disabled attribute is a boolean attribute.

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

Disabled option groups are not usable and cannot be clicked.

Can set the Disabled attribute to prevent users from selecting an option group until other conditions are met (such as checking a checkbox, etc.). Then, JavaScript is needed to remove the disabled value and make the option group selectable.

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

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

Syntax

<optgroup disabled>
 HTML <optgroup> tag