1. Computing & Technology

Discuss in my forum

<optgroup></optgroup>

By , About.com Guide

optgroup Description:

The optgroup HTML tag defines a group of options in a select list of an HTML form. It allows designers to style portions of the select list drop-down field and allows for labels of those groups within the list.

optgroup Web Browser Support:

HTML Versions

optgroup Attributes:

optgroup End Tag:

</optgroup> REQUIRED

optgroup Contents:

HTML. The following tags are valid within the optgroup tag:
option

optgroup Valid Context:

The optgroup tag is valid within the following tags:
select, form

optgroup Usage:

Typical option list with labels on option groups

<form action="#">
  <label for="list">Name your favorite pet</label>
  <select name="list">
    <optgroup label="mammals">
      <option>dog</option>
      <option>cat</option>
      <option>rabbit</option>
      <option>horse</option>
    </optgroup>
    <optgroup label="reptiles">
      <option>iguana</option>
      <option>snake</option>
    </optgroup>
  </select>
</form>

optgroup Special Notes:

  • Use this tag to create groups within the select options.

©2012 About.com. All rights reserved.

A part of The New York Times Company.