optgroups tag

I just found out about the HTML optgroups tag.  It basically adds a header to certain options within a dropdown.  I’m surprised that I had never heard about it before. There’s an example after the break.

Example:

Code:

<select name="example">
  <optgroup label="group one">
    <option>value one</option>
    <option>value alpha</option>
  </optgroup>
  <optgroup label="group two">
    <option>value two</option>
    <option>value beta</option>
  </optgroup>
</select>

syntax highlighted by Code2HTML, v. 0.9.1

 

Leave a comment