Introduction: 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>
</html>
Now, we run this code. The output will look like as below
When we Click on drop-down box, the list of
options are displayed with group name which is defined with <optgroup> tag. Like as
below figure