Share on Google+Share on Google+

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.

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:

<!doctype html >
<html >
<title>optgroup tag.</title>
<h1>Example of optgroup tag in HTML5.</h1>
<select style="width: 178px">
<optgroup label="Programming Language" >
<optgroup label="Language">
<option> English</option>
<optgroup label="Gender" disabled="disabled">

Download this code

Difference Between HTML5 and HTML4.01:

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



Posted on: September 10, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.