Sumari
En un formulari web, l'element HTML <optgroup>
crea una agrupació d'opcions dins d'un element <select>
.
Categories de contingut | Cap. |
---|---|
Contingut permès | Zero o més elements <option> . |
Omissió de l'etiqueta | L'etiqueta d'inici és obligatòria. L'etiqueta de tancament és opcional si aquest element és seguit immediatament per un altre element <optgroup> , o si l'element pare no té més contingut. |
Elements pares permesos | Un element <select> . |
Interfície DOM | HTMLOptGroupElement |
Note:
Optgroup elements may not be nested.Atributs
Aquest element inclou els atributs globals.
disabled
- Si aquest atribut booleà està establert, cap dels elements en aquest grup d'opcions es pot seleccionar. Sovint, els navegadors no habiliten aquest control i no reben cap esdeveniment de navegació, com clics del ratolí o els relacionats amb l'enfocament.
label
- El nom del grup d'opcions, que el navegador pot utilitzar en etiquetar les opcions de la interfície d'usuari. Aquest atribut és obligatori si s'utilitza aquest element.
Exemple
<select>
<optgroup label="Group 1">
<option>Option 1.1</option>
</optgroup>
<optgroup label="Group 2">
<option>Option 2.1</option>
<option>Option 2.2</option>
</optgroup>
<optgroup label="Group 3" disabled>
<option>Option 3.1</option>
<option>Option 3.2</option>
<option>Option 3.3</option>
</optgroup>
</select>
Resultat
Especificacions
Especificació | Estat | Comentari |
---|---|---|
HTML Living Standard The definition of '<optgroup>' in that specification. |
Living Standard | |
HTML5 The definition of '<optgroup>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<optgroup>' in that specification. |
Recommendation |
Navegadors compatibles
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Suport bàsic | 1.0 | (Yes) | (Yes) | (Yes) | (Yes) |
Característica | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Veure
- Altres elements relacionats amb formularis:
<form>
,<legend>
,<label>
,<button>
,<select>
,<datalist>
,<option>
,<fieldset>
,<textarea>
,<keygen>
,<input>
,<output>
,<progress>
and<meter>
.