Summary -

In this topic, we described about the <optgroup> tag along with detailed example.

Selection form control option group in HTML documents. The <optgroup> tag used to specify Selection form control option group. <optgroup> used to group the related options together in drop-down list.

This will be useful to handle the related options easy, if list of option are more. The tag can be specified like <optgroup></optgroup> with the related items in between the opening and closing tags.

Closing tag is not needed in case if another <optgroup> element immediately coded and other cases, closing tag is needed.

Syntax -


Example -

<!DOCTYPE html>
	<title>Optgroup tag example.. </title>
	Select from list:
		<optgroup label="India">
			<option value=" Andhra pradesh ">Andhra pradesh</option>
			<option value=" Telangana">Telangana</option>
		<optgroup label="US">
			<option value=" California">California</option>
			<option value="new jersy">New jersy</option>

Output -

Select from list -