HTML5 optgroup Example, Example of <optgroup> tag in HTML5.


 

HTML5 optgroup Example, Example of <optgroup> tag in HTML5.

Here, you will see the use of <optgroup> tag. it is use for grouping related option.

Here, you will see the use of <optgroup> tag. it is use for grouping related option.

HTML5 Optgroup Example, Example of <optgroup> tag in HTML5.

Here, we will introduce you to about <optgroup> tag of HTML5.With the help of this tag, you can make group of related option with a label. The label is a attribute of specifying name of group.

Attributes of optgroup:

Attributes  Value  Description 
disabled  disabled or empty  string or empty Element can not receives focus of user. 
label  string  Name of group 


Declaration Syntax :
Declaration syntax of optgroup in HTML5.

  <optgroup label="text"> option tag</optgroup >

Example of <optgroup > in HTML5:

Code:
OptGroup.html
<!doctype html >
<html >
<head>
<title>optgroup tag.</title>
</head><body>
<h1>Example of optgroup tag in HTML5.</h1>
<select style="width: 178px">
<optgroup label="Programming Language" >
<option>C</option>
<option>C++</option>
<option>Java</option></optgroup>
<optgroup label="Language">
<option>Hindi</option>
<option> English</option>
<option>Urdu</option>
</optgroup>
<optgroup label="Gender" disabled="disabled">
<option>Male</option>
<option>Female</option></optgroup>
</select></body>
</html>
Output:

Download this code

Difference Between HTML5 and HTML4.01:

The optgroup tag is available in both HTML5 and HTML4.01. So no difference.

Ads