Optgroup element


The <optgroup> element is used to group together related <option> elements within a parent <select> drop-down list.Try this code--

 <html>

<body>


<h1>The optgroup element</h1>


<Comment>The optgroup tag is used to group related options in a drop-down list:</comment>


  <label for="cars">Choose a car:</label>

  <select name="cars" id="cars">

    <optgroup label="Swedish Cars">

      <option value="volvo">Volvo</option>

      <option value="saab">Saab</option>

    </optgroup>

    <optgroup label="German Cars">

      <option value="mercedes">Mercedes</option>

      <option value="audi">Audi</option>

    </optgroup>

  </select>

  <br><br>

  <input type="submit" value="Submit">

</form>

 

</body>

</html>

Output will be-



Comments

Post a Comment

Popular posts from this blog

Frameset in HTML