The "optgroup" tag in HTML5
The <optgroup> tag is used
for group of options. Generally <optgroup> tag is used with drop-down box. Now,
we use this tag in our application. Write the following code:
- <!DOCTYPE HTML>
- <html>
- <select>
- <optgroup label="Computer Language">
- <option>C</option>
- <option>C++</option>
- <option>C#</option>
- <option>ASP.NET</option>
- </optgroup>
- <optgroup label="Database">
- <option>SQL SERVER</option>
- <option>ORACLE</option>
- <option>DB2</option>
- </optgroup>
- </select>
- </body>undefined</html>
Now, we run this code. The output will look like as below:
When we Click on the drop-down box, the list of options is displayed with the group name which is defined with <optgroup> tag. Like as
below figure: