The "optgroup" tag in HTML5

  • A K
  • A K
  • Updated date Oct 18 2019

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:
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <select>  
  4.         <optgroup label="Computer Language">  
  5.             <option>C</option>  
  6.             <option>C++</option>  
  7.             <option>C#</option>  
  8.             <option>ASP.NET</option>  
  9.         </optgroup>  
  10.         <optgroup label="Database">  
  11.             <option>SQL SERVER</option>  
  12.             <option>ORACLE</option>  
  13.             <option>DB2</option>  
  14.         </optgroup>  
  15.     </select>  
  16. </body>undefined</html>  
Now, we run this code. The output will look like as below:
 
<optgroup /> tah in html5
 
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:
 
 <optgroup /> tah in html5