<optgroup> tag

HTML <optgroup> tag

The <optgroup> tag gives an option to select an item from a group of  a drop down list.

You should code this tag inside the <select> tag to create a drop down list.

Syntax:
<optgroup label=”text”>…</optgroup>

Example

<select>
  <optgroup label="Select country">
    <option value="india">India</option>
    <option value="usa">USA</option>
    <option value="japan">Japan</option>
    <option value="canada">Canada</option>
    <option value="australia">Australia</option>
    <option value="brazil">Brazil</option>
  </optgroup>
</select>

Default value

NONE

How Browser will display

INLINE.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
None None None

Attributes used with <optgroup> tag

Attribute Description
label It defines a label for the option-group. It ia mandatory attribute and must be coded with the <optgroup> tag.
disabled It informs the browser that the option-group is disabled.

Global Attributes

The <optgroup> tag tag supports global attributes.

Event Attributes

The <optgroup> tag supports event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<select>, <form>, <fieldset>, <datalist><legend>, <textarea>, <input>, <label>, <button> and <option> tags.

Tutorials for all brains!