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.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 |
<optgroup label="text"> option tag</optgroup > |
<!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> |
The optgroup tag is available in both HTML5 and HTML4.01. So no difference.