18.3. Organizing Options into Groups: <optgroup>

If a selection list contains too many options, it may look disorganized. One possible solution to this problem is to organize the options into various groups. An option group is defined using the <optgroup></optgroup> tag pair. Its title attribute specifies the title of an option group.

The following WML example demonstrates how to use the <optgroup></optgroup> tags to organize options of a selection list:


<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">

  <card id="card1" title="Selection List">
      <select name="selection_list">
        <optgroup title="WML Tutorial Ch1">
          <option value="tutorial_1A">Part 1A</option>
          <option value="tutorial_1B">Part 1B</option>
        <optgroup title="WML Tutorial Ch2">
          <option value="tutorial_2A">Part 2A</option>
          <option value="tutorial_2B">Part 2B</option>


The following screenshots show the result of the above WML example in some mobile phone browsers:

Sony Ericsson T610

Sony Ericsson T68i

Nokia Mobile Browser 4.0

Previous Page Page 33 of 50 Next Page

Feedback Form (Expand)

What do you think about this web page?

WML Tutorial - Table of Contents WML Tutorial - Contents at a Glance Preferences - Light mode / Dark mode Preferences - Do Not Show Ads Previous Page Next Page