|
|
The Definition and UsageThe If you have a long list of options, groups of related options are easier to handle for a user. Browser Support
Attributes
Global AttributesThe Event AttributesThe |
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
<br><br>
<input type="submit" value="Submit">
</form>
The disabled attribute for <optgroup> element in HTML is used to specify that the option-group is disabled. A disabled optgroup is un-clickable and unusable. It is a boolean attribute.
The disabled attribute is a boolean attribute.
When present, it specifies that an option-group should be disabled.
A disabled option-group is unusable and un-clickable.
The disabled attribute can be set to keep a user from selecting the option-group until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the disabled value, and make the option-group selectable.
The numbers in the table specify the first browser version that fully supports the attribute.

<optgroup disabled>
A disabled option-group.
The optgroup disabled attribute
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<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>
<br><br>
<input type="submit" value="Submit">
</form>
The label attribute specifies a label for an option-group.

<optgroup label="text">
| Value | Description |
|---|---|
| text | Specifies a label/description for the option-group |
Two option-groups with labels.
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
<br><br>
<input type="submit" value="Submit">
</form>
| html optgroup |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Tag |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference